HomeDocssdk/python
Gateway Protocol v1 · Production Reference

Documentation

One key, two compatible wire protocols, 15 frontier models. Read the quickstart or explore the API reference.

Python SDK

There is no Selora-specific Python package — you install the official vendor SDK and point its base_url at the gateway. Both wire formats work, and the flavour you pick decides the base URL: the Anthropic SDK wants the bare origin, the OpenAI SDK wants origin plus /v1. Either way you swap models by changing one field.

Anthropic Wire Protocol

Anthropic

Base URL

https://api.selora.lol
SDK automatically appends /v1/messagesAuthenticate via x-api-key: sk-gw-...

OpenAI Wire Protocol

OpenAI

Base URL

https://api.selora.lol/v1
SDK automatically appends /chat/completionsAuthenticate via Authorization: Bearer sk-gw-...

Protocol Header Resolution: The gateway inspects x-api-key first and falls back to Authorization: Bearer. Both wire formats accept standard sk-gw-... gateway keys. Notice that the Anthropic URL is the bare origin (because official Anthropic SDKs append /v1/messages), while OpenAI tooling takes .../v1 (because OpenAI SDKs append /chat/completions).

Anthropic flavour — pip install anthropic
python
import os
from anthropic import Anthropic

client = Anthropic(
    api_key=os.environ["SELORA_API_KEY"],   # sk-gw-…, sent as x-api-key
    base_url="https://api.selora.lol",           # origin only — no /v1
)

message = client.messages.create(
    model="claude-sonnet-5",
    max_tokens=512,                         # required on /v1/messages
    messages=[{"role": "user", "content": "Summarize this diff in one line."}],
)
print(message.content[0].text)
OpenAI flavour — pip install openai
python
import os
from openai import OpenAI

client = OpenAI(
    api_key=os.environ["SELORA_API_KEY"],   # sk-gw-…, sent as Authorization: Bearer
    base_url="https://api.selora.lol/v1",         # origin + /v1
)

resp = client.chat.completions.create(
    model="kimi-k3",
    messages=[{"role": "user", "content": "Summarize this diff in one line."}],
)
print(resp.choices[0].message.content)

Both SDKs raise typed exceptions on a 429 or 5xx, so you can retry on the exception rather than string-matching response bodies. The model ids are identical across the two flavours — the Models page lists what is routable today.