Ta strona jest dostępna tylko po angielsku.

OpenAI SDK

Aile's /v1/chat/completions is the OpenAI wire format exactly. Change the base URL; nothing else moves.

Pythonpython
1import os
2from openai import OpenAI
3
4client = OpenAI(
5 base_url="https://api.aile.sh/v1",
6 api_key=os.environ["AILE_KEY"],
7)
8
9resp = client.chat.completions.create(
10 model="cc/claude-sonnet-5",
11 messages=[{"role": "user", "content": "Say hello."}],
12 max_tokens=256,
13)
14print(resp.choices[0].message.content)

The base URL keeps the /v1

OpenAI clients append /chat/completions to whatever you give them, so the correct value is https://api.aile.sh/v1. Omitting /v1 produces a 404. That is not an auth error. The Anthropic SDK is the opposite: it takes the bare origin, https://api.aile.sh.

Any model in the catalogue

The endpoint decides the wire format; the model you name still comes from the whole catalogue, and names its provider (cc/claude-sonnet-5; a bare claude-sonnet-5 needs x-aile-provider). cc/claude-sonnet-5 through the OpenAI SDK works, because Aile translates between shapes. See Model names.

Translated replies keep OpenAI's meanings: a Claude reply stopped by its context window ends with finish_reason: "length", as one stopped by max_tokens does. reasoning_effort reaches Claude models as their own thinking settings; see Models that always think. GET /v1/models lists each model's list price as a ceiling (pricing, cache rates included), its context window and its effort levels.

Sending Aile headers

The Python and Node clients both take per-request extra headers, which is how you reach the routing levers:

Pythonpython
1resp = client.chat.completions.create(
2 model="cc/claude-sonnet-5",
3 messages=[{"role": "user", "content": "Say hello."}],
4 extra_headers={
5 "x-aile-max-price": "8",
6 "x-aile-verified": "1",
7 },
8)

If your client cannot set headers at all, pin the same filters to the key instead. See API keys.

Frameworks

Anything that accepts an OpenAI-compatible base URL works unchanged:

  • LangChain: ChatOpenAI(base_url=..., api_key=...)
  • LlamaIndex: OpenAI(api_base=..., api_key=...)
  • Vercel AI SDK: createOpenAICompatible({ baseURL, apiKey })
  • LiteLLM: configure an openai/ model with api_base

Embeddings

Pythonpython
1client.embeddings.create(model="openai/text-embedding-3-small", input="…")

Buffered only: no streaming, no failover loop, and its own bounded provider set. The model is always <provider>/<model>. Everything else about the surface is the same.

Reading the decision

Every response carries headers saying who served it and at what price. In Node:

TypeScripttypescript
1const res = await client.chat.completions
2 .create({ model: "cc/claude-sonnet-5", messages })
3 .withResponse();
4
5console.log(res.response.headers.get("x-aile-sharer"));
6console.log(res.response.headers.get("x-aile-price"));

x-aile-price is the quote; a key's balance can be billed past it with no max_tokens (as here), on a route that sends no cap (codex), when tools or thinking raise the cap sent upstream, or when the provider reports cache writes (billed at up to 2x input). An x402 payment is the quote exactly: a body with no cap is sent the one it was priced on, and a route that sends no cap, or would send more than was priced, is a 400.

Full list: Headers.