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.
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.
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.
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.
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.
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).
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.
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.
| Dialect | Endpoint | For |
|---|---|---|
| OpenAI Chat | POST /v1/chat/completions | The default; most SDKs and tools |
| Anthropic Messages | POST /v1/messages | Claude Code and Anthropic SDKs; system and history are native |
| OpenAI Responses | POST /v1/responses | Codex 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.
Every param, honored or dropped.
Standard OpenAI parameters
| Param | Honored | Default | Notes |
|---|---|---|---|
messages | Yes | required | System prompt and full history passed through |
tools, tool_choice | Yes | none | Triggers the tool-calling path |
stream | Yes | false | Server-sent events. Sent in chunks once the check is done, not token by token |
stream_options | partial | none | Only include_usage is read |
response_format | Yes | none | {"type":"json_object"} passed through |
max_tokens | Yes | see note | Caps 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. |
temperature | Yes | maker default | Passed 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). |
model | Yes | tirtha/auto | catalog/<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_p | Yes | maker default | Passed to every host that accepts it, on every level and on a catalog/<slug> pick |
stop | Yes | - | Passed to every host that accepts it |
top_k, presence_penalty, frequency_penalty, seed | Yes | maker default | Passed to every host that accepts them |
Tīrtha extensions (body.tirtha.*)
| Field | Type | Default | Purpose |
|---|---|---|---|
mode | string | auto | How 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_cache | boolean | false | Skip 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. |
domain | string | key default | Scope tag for reuse of solved work |
subdomain | string | key default | Sub-scope tag |
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.
| Field | Meaning |
|---|---|
served_by | Which path answered: the id of the Base model that served it, frontier-value (Plus) / frontier-max (Max), cache-exact. |
checked / checked_by | checked: 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_check | passed 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). |
escalated | true only if the request moved up a level (with tirtha/auto). A pinned level reads false. |
mode | The care dial in effect for this request (auto/value/quality/max; low is reported as value). |
served_level | Present when the level that served differs from the one you pinned. |
billed_usd | What this request cost you. |
max_redirect | Present 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_stop | Present 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.
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.
| Status | Type | Meaning |
|---|---|---|
400 | invalid mode | Unknown tirtha.mode, or frontier. The body lists the valid options. |
400 | context limit | Tool request over 125,000 tokens. Compact the conversation and retry. |
401 | invalid_api_key | Missing or bad Bearer key. Today some 401s from our network edge arrive without this JSON body; a fix is in progress. |
402 | insufficient_credits | Credit balance empty. The body carries balance and buy_url. |
429 | rate_limit_error | Per-key rate exceeded. Honor Retry-After. |
429 | server_busy | At capacity; retry after Retry-After |
429 | credit_reserve_busy | Low credit balance: one request at a time |
429 | runaway_guard | The same large request is looping, or Max is being hit too often. Paused for the Retry-After period (up to 15 minutes). |
502 | truncated_tool_call | The tool reply hit its output limit. Retry with a larger max_tokens. |
503 | backends_unavailable | The 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. |
503 | billing_unavailable | Your balance could not be read. Retry shortly. |
200 | tirtha.session_stop | Auto-mode session reached 80 requests or $2. The reply asks the agent to stop and report. |
200 | tirtha.spend_capped:true | Daily spend cap reached; served on the lower cost path, never a silent switch |
200 | tirtha.premium_limited:true | Included premium allowance reached; served on the lower cost path |
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.