Indicia Code.

SDK examples

Stream with the OpenAI and Anthropic SDKs in Python and TypeScript.

Both SDKs work against the gateway once you change the base URL and the API key. The OpenAI SDK takes the base URL with /v1; the Anthropic SDK takes the bare host.

Streaming

Terminal
pip install openai anthropic
stream.py
import os
from anthropic import Anthropic
from openai import OpenAI

openai = OpenAI(base_url="https://code.test.indicia-ai.com/v1", api_key=os.environ["INDICIA_TOKEN"])
anthropic = Anthropic(base_url="https://code.test.indicia-ai.com", api_key=os.environ["INDICIA_TOKEN"])

# Chat Completions, streamed
stream = openai.chat.completions.create(
    model="indicia/snel",
    messages=[{"role": "user", "content": "Write a haiku about failover."}],
    stream=True,
)
for chunk in stream:
    if chunk.choices and chunk.choices[0].delta.content:
        print(chunk.choices[0].delta.content, end="", flush=True)
print()

# Messages, streamed
with anthropic.messages.stream(
    model="claude-sonnet-5-5",
    max_tokens=1024,
    messages=[{"role": "user", "content": "Write a haiku about failover."}],
) as stream:
    for text in stream.text_stream:
        print(text, end="", flush=True)
print()

Which model answered

To see which model answered a Chat Completions request, read the response headers:

which_model.py
raw = openai.chat.completions.with_raw_response.create(
    model="indicia/snel",
    messages=[{"role": "user", "content": "Say hello"}],
)
print(raw.headers["x-indicia-provider"], raw.headers["x-indicia-model"])
completion = raw.parse()

On this page