SDKs & Libraries

Quantized is OpenAI-compatible for chat completions, responses, and embeddings. You can use the official OpenAI SDKs by pointing them at https://api.quantized.us/v1.

OpenAI Python SDK

pip install openai
from openai import OpenAI

client = OpenAI(
    api_key="sk-quantized-YOUR-KEY",
    base_url="https://api.quantized.us/v1",
)

# Chat completion
response = client.chat.completions.create(
    model="openai/gpt-4.1-mini",
    messages=[{"role": "user", "content": "Hello!"}],
)
print(response.choices[0].message.content)

# Streaming
stream = client.chat.completions.create(
    model="openai/gpt-4.1-mini",
    messages=[{"role": "user", "content": "Write a haiku about code."}],
    stream=True,
)
for chunk in stream:
    # Final chunks may use an empty `choices` list (e.g. usage-only); skip those.
    if not chunk.choices:
        continue
    delta = chunk.choices[0].delta
    if delta and delta.content:
        print(delta.content, end="")

# Embeddings
embedding = client.embeddings.create(
    model="text-embedding-3-small",
    input=["one", "two", "three"],
)
print(len(embedding.data), len(embedding.data[0].embedding))

OpenAI JavaScript/TypeScript SDK

npm install openai
import OpenAI from 'openai';

const client = new OpenAI({
  apiKey: 'sk-quantized-YOUR-KEY',
  baseURL: 'https://api.quantized.us/v1',
});

const response = await client.chat.completions.create({
  model: 'openai/gpt-4.1-mini',
  messages: [{ role: 'user', content: 'Hello!' }],
});

console.log(response.choices[0].message.content);

Direct HTTP (Python httpx)

import httpx

response = httpx.post(
    "https://api.quantized.us/v1/chat/completions",
    headers={"Authorization": "Bearer sk-quantized-YOUR-KEY"},
    json={
        "model": "openai/gpt-4.1-mini",
        "messages": [{"role": "user", "content": "Hello!"}],
    },
)
print(response.json())

Direct HTTP (cURL)

curl -X POST https://api.quantized.us/v1/chat/completions \
  -H "Authorization: Bearer sk-quantized-YOUR-KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "model": "openai/gpt-4.1-mini",
    "messages": [{"role": "user", "content": "Hello!"}]
  }'

Model naming

Models use an author/model naming convention. The prefix names who made the model, not the provider that serves it:

Model ID Author Model
openai/gpt-4.1-mini OpenAI GPT-4.1 Mini
openai/gpt-4.1-nano OpenAI GPT-4.1 Nano
anthropic/claude-sonnet-4 Anthropic Claude Sonnet 4
anthropic/claude-sonnet-4.6 Anthropic Claude Sonnet 4.6
meta-llama/llama-3.3-70b-instruct Meta Llama 3.3 70B Instruct

The router picks the provider that serves each request among those that carry the model. See Providers for how it chooses and how to pin one with X-Quantized-Provider.

Use the Models endpoint to list all available models and their pricing.

Quantized headers

The SDKs let you send extra headers, for example to pin a provider or tag requests with X-Quantized-Metadata:

client = OpenAI(
    api_key="sk-quantized-YOUR-KEY",
    base_url="https://api.quantized.us/v1",
    default_headers={"X-Quantized-Provider": "openrouter"},
)
const client = new OpenAI({
  apiKey: 'sk-quantized-YOUR-KEY',
  baseURL: 'https://api.quantized.us/v1',
  defaultHeaders: { 'X-Quantized-Provider': 'openrouter' },
});

CORS is enabled, so you can also call the API from a browser. The OpenAI JavaScript SDK refuses to run there unless you pass dangerouslyAllowBrowser: true; only do that with a key you are willing to expose to the page’s users, such as a per-user JWT.

Web search and fetch

These endpoints are Quantized-specific (not OpenAI-compatible), so use them via direct HTTP calls:

# Web search
response = httpx.post(
    "https://api.quantized.us/v1/web-search",
    headers={"Authorization": "Bearer sk-quantized-YOUR-KEY"},
    json={"query": "Python 3.13 release date", "num_results": 5},
)

# Fetch content
response = httpx.post(
    "https://api.quantized.us/v1/fetch",
    headers={"Authorization": "Bearer sk-quantized-YOUR-KEY"},
    json={"urls": ["https://docs.python.org/3/whatsnew/3.13.html"]},
)