Back to home

API Documentation

Learn how to integrate Veleen into your application and start saving on AI costs.

Quick Start

1. Get your API key

Sign up for a free account and create an API key from the API Keys page. Your key will look like lk_xxxxx.

2. Add your provider keys

When creating your Veleen API key, add your existing provider API keys (Anthropic, OpenAI, etc.). These are securely encrypted and used to forward requests to the providers.

3. Update your base URL

Replace your provider's base URL with Veleen's gateway. That's it!

Code Examples

Python (Anthropic)

from anthropic import Anthropic

client = Anthropic(
    api_key="lk_your_veleen_key",  # Your Veleen API key
    base_url="https://gateway.veleen.com"
)

response = client.messages.create(
    model="claude-sonnet-4-20250514",
    max_tokens=1024,
    messages=[
        {"role": "user", "content": "Hello, Claude!"}
    ]
)

print(response.content[0].text)

Python (OpenAI)

from openai import OpenAI

client = OpenAI(
    api_key="lk_your_veleen_key",  # Your Veleen API key
    base_url="https://gateway.veleen.com/v1"
)

response = client.chat.completions.create(
    model="gpt-4o",
    messages=[
        {"role": "user", "content": "Hello, GPT!"}
    ]
)

print(response.choices[0].message.content)

TypeScript

import Anthropic from "@anthropic-ai/sdk";

const client = new Anthropic({
  apiKey: "lk_your_veleen_key",
  baseURL: "https://gateway.veleen.com",
});

const response = await client.messages.create({
  model: "claude-sonnet-4-20250514",
  max_tokens: 1024,
  messages: [{ role: "user", content: "Hello!" }],
});

console.log(response.content[0].text);

cURL

curl https://gateway.veleen.com/v1/messages \
  -H "Content-Type: application/json" \
  -H "x-api-key: lk_your_veleen_key" \
  -H "anthropic-version: 2023-06-01" \
  -d '{
    "model": "claude-sonnet-4-20250514",
    "max_tokens": 1024,
    "messages": [{"role": "user", "content": "Hello!"}]
  }'

Compression Modes

Veleen offers three compression modes to balance savings with output quality:

Conservative

Safest option with minimal risk of meaning change. Removes only obvious redundancies.

15-25% savings

Balanced

Recommended

Good trade-off between savings and safety. Smart compression with quality preservation.

25-35% savings

Aggressive

Maximum savings. Best for non-critical or high-volume use cases. Review outputs recommended.

35-50% savings

API Reference

Base URL

https://gateway.veleen.com

Supported Endpoints

POST/v1/messagesAnthropic Messages API
POST/v1/chat/completionsOpenAI Chat API

Headers

HeaderDescription
x-api-keyYour Veleen API key
Content-Typeapplication/json
x-compression-modeOptional: conservative, balanced, aggressive

Response Headers

Veleen adds custom headers to responses so you can track your savings:

HeaderDescription
x-original-tokensOriginal input token count
x-compressed-tokensCompressed input token count
x-tokens-savedNumber of tokens saved
x-savings-percentPercentage savings achieved

Need Help?

If you have questions or need assistance, we're here to help: