Tīrtha is still being built, so some features and models may not work as expected yet. Billing always follows the prices shown. Something broken? Email [email protected].

Tīrtha
API reference

Change the base URL. Keep your code.

Tīrtha speaks three dialects: OpenAI Chat, Anthropic Messages, and OpenAI Responses. Plain text, tools, and streaming work on all three. Below are copy-paste examples, the full config reference, and the error codes.

Tīrtha is still in internal testing. Keys, limits and prices may change.

Quickstart

One base URL, one key.

Any OpenAI-compatible client works. Point it at https://api.tirtha.ai/v1, use your key from the dashboard, and set the model to tirtha/auto to let Tīrtha pick, or to catalog/<slug> for one model from the catalogue. Using a coding tool? See Setting up other tools.

# Mac / Linux. Set your key once: export TIRTHA_API_KEY=sk-tirtha-... # Redeem a credit code (optional) curl https://api.tirtha.ai/v1/billing/redeem \ -H "Authorization: Bearer $TIRTHA_API_KEY" \ -H "Content-Type: application/json" \ -d '{"code": "YOUR-CODE"}' # Chat curl https://api.tirtha.ai/v1/chat/completions \ -H "Authorization: Bearer $TIRTHA_API_KEY" \ -H "Content-Type: application/json" \ -d '{ "model": "tirtha/auto", "messages": [{"role": "user", "content": "Write a function that reverses a string."}] }'
# Windows PowerShell or PowerShell 7. Set your key once: $env:TIRTHA_API_KEY = "sk-tirtha-..." $headers = @{ Authorization = "Bearer $env:TIRTHA_API_KEY" } # Redeem a credit code (optional) $redeem = @{ code = "YOUR-CODE" } | ConvertTo-Json Invoke-RestMethod -Method Post -Uri "https://api.tirtha.ai/v1/billing/redeem" -Headers $headers ` -ContentType "application/json; charset=utf-8" -Body ([Text.Encoding]::UTF8.GetBytes($redeem)) # Chat $body = @{ model = "tirtha/auto" messages = @(@{ role = "user"; content = "Write a function that reverses a string." }) } | ConvertTo-Json -Depth 5 $r = Invoke-RestMethod -Method Post -Uri "https://api.tirtha.ai/v1/chat/completions" -Headers $headers ` -ContentType "application/json; charset=utf-8" -Body ([Text.Encoding]::UTF8.GetBytes($body)) $r.choices[0].message.content
# pip install openai Set your key once: export TIRTHA_API_KEY=sk-tirtha-... import os from openai import OpenAI client = OpenAI(base_url="https://api.tirtha.ai/v1", api_key=os.environ["TIRTHA_API_KEY"]) r = client.chat.completions.create( model="tirtha/auto", messages=[{"role": "user", "content": "Write a function that reverses a string."}], ) print(r.choices[0].message.content)
// Node 18+. Set TIRTHA_API_KEY in your environment (never put your key in a web page). const res = await fetch("https://api.tirtha.ai/v1/chat/completions", { method: "POST", headers: { "Authorization": `Bearer ${process.env.TIRTHA_API_KEY}`, "Content-Type": "application/json", }, body: JSON.stringify({ model: "tirtha/auto", messages: [{ role: "user", content: "Write a function that reverses a string." }], }), }); const data = await res.json(); console.log(data.choices[0].message.content);

Redeeming a code needs the Terms accepted first: a 428 terms_not_accepted reply means accept them once in your dashboard, then try again. Send the key as Authorization: Bearer sk-tirtha-...; an api-key or x-goog-api-key header, or a key in the URL, is refused. In Windows PowerShell, curl is a different command, so use the PowerShell tab or call curl.exe. Reference: Invoke-RestMethod.

Chat completions

The primary path.

POST /v1/chat/completions. Standard OpenAI request and response shapes. System prompts and multi-turn history are passed through. The response is the OpenAI shape you already parse.

# -> 200 { "id": "chatcmpl-…", "object": "chat.completion", "choices": [{ "index": 0, "message": {"role":"assistant","content":"def reverse(s): return s[::-1]"}, "finish_reason": "stop" }], "usage": {"prompt_tokens":18,"completion_tokens":9,"total_tokens":27} }

Note: leave model out, or send tirtha/auto, and Tīrtha picks the model for each task; your temperature, top_p, top_k, penalties, seed and stop are passed to every host that accepts them. A host that doesn't accept a setting ignores it. With none set, the model runs at its default (on Plus, temperature 1.0). To pick a model yourself, send "model": "catalog/<slug>", where the slug is a model id from /v1/pricing. That model serves the request at its listed price, the request does not move up a level, and your sampling settings (temperature, top_p, top_k, penalties, seed, stop) are passed to every host that accepts them. A host that doesn't accept a setting ignores it. Tīrtha does not check the answer on a model you pick. It only refuses tool calls that name a tool you did not offer or carry malformed arguments, and those are never billed. If its host is down, another host of the same model may serve it, at the same listed price. See the config reference below for the full honored-versus-ignored list.

Streaming

Server-sent events, usage on the last chunk.

Set stream: true. Tool calls are checked against your schema before anything is sent, so the stream arrives in chunks after the check, not token by token. To get token usage in the stream, set stream_options: {"include_usage": true} and read it from the final chunk. On a slow turn (usually one that moves up a level) the stream sends an SSE comment line, : keepalive, every 5 to 10 seconds until the answer is ready; standard SSE clients ignore it. If the model returns reasoning, it arrives as reasoning_content (in delta when streaming, in message otherwise).

curl https://api.tirtha.ai/v1/chat/completions \ -H "Authorization: Bearer sk-tirtha-…" \ -d '{ "model":"tirtha/auto", "stream":true, "stream_options":{"include_usage":true}, "messages":[{"role":"user","content":"…"}] }' # SSE frames : keepalive data: {"choices":[{"delta":{"content":"def "}}]} data: {"choices":[{"delta":{"content":"reverse"}}]} data: {"choices":[{"delta":{}}],"usage":{"total_tokens":27}} data: [DONE]
Tool calling

OpenAI wire format, checked before it is served.

Send tools and, if you want, tool_choice. Tool calls come back in the OpenAI tool_calls shape, identical across all three dialects. Every tool call passes an internal check before it reaches you.

{ "model": "tirtha/auto", "messages": [{"role":"user","content":"What is the weather in Paris tomorrow?"}], "tools": [{"type":"function","function":{ "name":"get_forecast", "parameters":{"type":"object","properties":{"city":{"type":"string"},"day":{"type":"string"}}} }}] } # -> assistant turn "tool_calls": [{"id":"call_1","type":"function", "function":{"name":"get_forecast","arguments":"{\"city\":\"Paris\",\"day\":\"tomorrow\"}"}}]
Dialects

Same engine, three front doors.

Point Claude Code at Messages, point Codex at Responses, point everything else at Chat. Tools and streaming work on all three.

DialectEndpointFor
OpenAI ChatPOST /v1/chat/completionsThe default; most SDKs and tools
Anthropic MessagesPOST /v1/messagesClaude Code and Anthropic SDKs; system and history are native
OpenAI ResponsesPOST /v1/responsesCodex and the Responses SDK

The reply is translated back into the dialect you called, so your existing client parses it unchanged. Usage fields and stop reasons follow each dialect's own convention.

Config reference

Every param, honored or dropped.

Standard OpenAI parameters

ParamHonoredDefaultNotes
messagesYesrequiredSystem prompt and full history passed through
tools, tool_choiceYesnoneTriggers the tool-calling path
streamYesfalseServer-sent events. Sent in chunks once the check is done, not token by token
stream_optionspartialnoneOnly include_usage is read
response_formatYesnone{"type":"json_object"} passed through
max_tokensYessee noteCaps each model call, except on long agent sessions (below). Default: 4,096 output tokens on every level, 16,384 on long agent sessions. On auto, a request that moves up a level is billed at the level that answered, and billed output can be more than max_tokens. If a request moves up a level, its first Base attempt is also billed, at Base rates, even if that attempt returned an empty or unusable answer. On long agent sessions (4+ tool turns or 24K+ input tokens), tool calls are given room to finish: the model may use up to 16,384 output tokens, even if max_tokens is lower. You are billed only for the tokens actually generated, shown in usage.completion_tokens and billing.
temperatureYesmaker defaultPassed to every host that accepts it, on every level and on a catalog/<slug> pick. Unset, the model runs at its default (on Plus, 1.0).
modelYestirtha/autocatalog/<slug> picks that model at its listed price. Any other model name, such as tirtha/auto or tirtha/plus, is ignored: the level comes from tirtha.mode (quality = Plus, max = Max) or your key's default.
top_pYesmaker defaultPassed to every host that accepts it, on every level and on a catalog/<slug> pick
stopYes-Passed to every host that accepts it
top_k, presence_penalty, frequency_penalty, seedYesmaker defaultPassed to every host that accepts them

Tīrtha extensions  (body.tirtha.*)

FieldTypeDefaultPurpose
modestringautoHow hard Tīrtha works on each request. auto (default): With tirtha/auto, Tīrtha picks the model for each task by price, speed and accuracy, checks each tool call against your schema before serving it, and moves up a level when the check fails; billed at the level that answered. If a request moves up a level, its first Base attempt is also billed, at Base rates, even if that attempt returned an empty or unusable answer. On auto, long agent sessions move up to Plus at most. value: always Base, never moves up (low is the same as value). quality: always Plus. max: always Max, for single accurate calls. Long agent sessions (4+ tool turns or 24K+ input tokens) pinned to Max are served and billed at Plus. The response says max_redirect. frontier: not available yet, returns 400. Pinned prices are on /pricing. Set it per request as "tirtha": {"mode": "quality"}, or once on your key. A request setting overrides the key, and the key overrides your account. An unknown mode returns 400 and lists the valid ones.
no_cachebooleanfalseSkip the cache for this request, both directions: nothing is read from it and nothing is written to it. Use it when the prompt carries something you do not want stored. Read this with the privacy note: when an answer passes verification we store it together with the prompt that produced it, in a store that is shared by default, so no_cache is the per-request opt out. Without the flag, a repeated request can come back served_by: cache-exact; with it, every call goes to the model.
domainstringkey defaultScope tag for reuse of solved work
subdomainstringkey defaultSub-scope tag
Response & the refuse contract

Which tier answered, and whether it was checked.

Every response carries a tirtha object beside the standard OpenAI fields, so you always know which tier served the answer and whether it passed the gate.

FieldMeaning
served_byWhich path answered: the id of the Base model that served it, frontier-value (Plus) / frontier-max (Max), cache-exact.
checked / checked_bychecked: true means every tool call in this response passed the schema check; false means a call failed it (on Plus and Max the failing call is removed; on pinned Base it is returned after one retry) or no check applied. checked_by names the check that passed, for example schema, and is null when checked is false.
schema_checkpassed or failed on every tool-call answer from tirtha/auto or a pinned level; null when no schema check ran (for example a text or chat answer).
escalatedtrue only if the request moved up a level (with tirtha/auto). A pinned level reads false.
modeThe care dial in effect for this request (auto/value/quality/max; low is reported as value).
served_levelPresent when the level that served differs from the one you pinned.
billed_usdWhat this request cost you.
max_redirectPresent only when the request was pinned to Max (tirtha.mode "max") and was a long agent session (4+ tool turns or 24K+ input tokens). Value "long_agent_session". The request was served and billed at Plus (see served_level and billing.level). Auto requests never carry this field: on auto, long agent sessions move up to Plus at most.
session_stopPresent when the auto-mode session cap was reached (requests or spend).

The refuse contract (tool-calling)

The core reliability promise: on the primary path, Tīrtha does not serve a tool call that fails your schema. The failover result is on /capabilities. When the model is not confident a tool applies, it does not invent a call and does not return an error. It returns a normal 200 with an empty tool_calls array and plain text explaining the limit, with checked:false. A malformed or schema-invalid call moves up a level first; only if no valid call can be produced is the empty-call answer returned.

# Trap: only a CURRENT-weather tool exists; asked for a 3-day forecast { "choices": [{ "message": { "content": "I can only retrieve the current weather. I can't forecast future dates.", "tool_calls": [] # refused, no invented call }}], "tirtha": { "served_by":"<base model id>", "checked":false, "escalated":false } }
Errors

What comes back when it will not serve.

Errors follow the OpenAI error shape and carry a code. Retry anything that sends a Retry-After header after that interval. Hitting your daily spend cap does not fail: it serves on the lower cost path and tells you so in the response.

StatusTypeMeaning
400invalid modeUnknown tirtha.mode, or frontier. The body lists the valid options.
400context limitTool request over 125,000 tokens. Compact the conversation and retry.
401invalid_api_keyMissing or bad Bearer key. Today some 401s from our network edge arrive without this JSON body; a fix is in progress.
402insufficient_creditsCredit balance empty. The body carries balance and buy_url.
429rate_limit_errorPer-key rate exceeded. Honor Retry-After.
429server_busyAt capacity; retry after Retry-After
429credit_reserve_busyLow credit balance: one request at a time
429runaway_guardThe same large request is looping, or Max is being hit too often. Paused for the Retry-After period (up to 15 minutes).
502truncated_tool_callThe tool reply hit its output limit. Retry with a larger max_tokens.
503backends_unavailableThe level that would serve this request is unavailable or failing right now. The response carries a Retry-After header (seconds); retry after that. A request pinned to a level (tirtha.mode quality or max) gets this at once while that level is failing, rather than waiting for a timeout. Requests no longer hang: each level has a time limit.
503billing_unavailableYour balance could not be read. Retry shortly.
200tirtha.session_stopAuto-mode session reached 80 requests or $2. The reply asks the agent to stop and report.
200tirtha.spend_capped:trueDaily spend cap reached; served on the lower cost path, never a silent switch
200tirtha.premium_limited:trueIncluded premium allowance reached; served on the lower cost path
{ "error": { "type":"rate_limit_error", "message":"Rate limit exceeded. Retry after 60s." } }
More

The rest of the story.

The server info card has the capabilities matrix, limits, cache policy, and the honesty block. Security has the data posture. Pricing has the plans. Found a wrong answer? Write to [email protected] and we send a receipt.

In internal testing. API reference current as of 2026-10-26.