Python: call any model with the official OpenAI or Anthropic SDK

666 AI speaks both the OpenAI format (/v1/chat/completions, /v1/responses, /v1/embeddings) and the Anthropic format (/v1/messages). Keep your existing code, change two lines.

Replace YOUR-ENDPOINT with the endpoint shown on your API Key page after you sign up, and YOUR-KEY with your key. One key works for every model on 666 AI — Claude, GPT, Gemini, DeepSeek, Qwen and 200+ more.

1. OpenAI SDK — chat

pip install openai

from openai import OpenAI

client = OpenAI(
    base_url="https://YOUR-ENDPOINT/v1",
    api_key="YOUR-KEY",
)

resp = client.chat.completions.create(
    model="anthropic/claude-haiku-5.5",
    messages=[{"role": "user", "content": "Say hi in 3 words."}],
    max_tokens=200,
)
print(resp.choices[0].message.content)

2. Streaming

stream = client.chat.completions.create(
    model="anthropic/claude-haiku-5.5",
    messages=[{"role": "user", "content": "Count from 1 to 5."}],
    max_tokens=200,
    stream=True,
)
for chunk in stream:
    if chunk.choices:
        print(chunk.choices[0].delta.content or "", end="", flush=True)

3. Responses API (OpenAI / Gemini models)

resp = client.responses.create(
    model="google/gemini-3.5-flash",     # Claude models don't use /v1/responses — call them via chat completions or /v1/messages
    input="Say hi in 3 words.",
    max_output_tokens=200,
)
print(resp.output_text)

4. Embeddings

emb = client.embeddings.create(
    model="openai/text-embedding-3-small",
    input="hello",
)
print(len(emb.data[0].embedding))   # 1536

5. Or use environment variables

export OPENAI_BASE_URL="https://YOUR-ENDPOINT/v1"
export OPENAI_API_KEY="YOUR-KEY"
# then simply: client = OpenAI()

6. Anthropic SDK (Messages API)

pip install anthropic

import anthropic

client = anthropic.Anthropic(
    base_url="https://YOUR-ENDPOINT",   # no /v1 here — the SDK adds /v1/messages itself
    api_key="YOUR-KEY",
)

msg = client.messages.create(
    model="anthropic/claude-haiku-5.5",
    max_tokens=200,
    messages=[{"role": "user", "content": "Say hi in 3 words."}],
)
print(msg.content[0].text)

# streaming
with client.messages.stream(
    model="anthropic/claude-haiku-5.5",
    max_tokens=200,
    messages=[{"role": "user", "content": "Count from 1 to 5."}],
) as s:
    for text in s.text_stream:
        print(text, end="", flush=True)

Which model ID?

Use the exact ID shown on each model page, e.g. anthropic/claude-opus-5.5, google/gemini-3.5-flash. The same key works for all of them; you pay per use, no subscription.

FAQ

Do I need to change my code to switch models?

No. Only the model string changes; the client, base URL and key stay the same.

Why is the response empty?

Reasoning models can spend all of max_tokens on thinking. Raise max_tokens (2,000 or more).

OpenAI or Anthropic SDK — which should I use?

Either. Claude models work through both; other models are easiest through the OpenAI SDK.

Create a free accountAll modelsDeveloper guides