Reference / API

API

Every inference route, its request and its response.

Calling the API

This page lists every route you call models through, generated from the API itself: what each route does, the fields its request takes and what it answers.

The base URL is https://api.shardio.ai/v1. Inference routes are also served under https://api.shardio.ai/openai/v1, so a tool that expects an OpenAI path works there unchanged. Send your API key as a bearer token, Authorization: Bearer tsk_live_…, on authenticated routes. List prices and the marketplace model document below are public; the marketplace document is served only at its explicit /v1/marketplaces/openrouter/models path.

A refused request answers with an error object carrying a message, a type and a code. Errors explains every code and what to do about it.

Thinking controls

Chat completions accept a flat reasoning_effort or an OpenRouter-style reasoning object with effort and enabled. For example, "reasoning_effort": "medium" and "reasoning": {"effort": "medium"} choose the same effort on a model that supports it. This is support for those two object fields, not every OpenRouter reasoning control: reasoning.max_tokens and reasoning.exclude are rejected. The separate top-level max_tokens still limits total output; it is not a thinking-only budget.

The accepted choices depend on the model. none turns thinking off only where the model allows it. Models with effort levels accept their declared levels; XHigh (xhigh) is not Max (max). A toggle-only model has no tiers: any of minimal, low, medium, high, xhigh or max turns thinking on. SuperVL's native on is an extension, not an alias for high. Mandatory-thinking models refuse off settings.

Use "reasoning": {"enabled": true} to enable thinking without selecting an effort. If a level-based model defaults to off, this selects its declared enabled default; otherwise it leaves the enabled default in place. false turns thinking off where allowed. Omitting all thinking controls keeps the model's own default.

If you send more than one control, they must agree on the model's resulting setting. An enabled switch can accompany any supported non-off effort, but enabled: false conflicts with one. Different native levels conflict; two efforts that both mean On for a toggle-only model agree. The same rule covers enable_thinking and the controls in chat_template_kwargs. Unsupported or conflicting thinking settings are refused with reasoning_effort_unsupported before a credit hold or model dispatch.

Discovering thinking choices

Read each model's optional reasoning object from the public /catalog, or from the authenticated /v1/models list. In both responses it sits directly on the model object, not inside shardio. The public catalog's separate supports_reasoning flag describes separated thinking output, not the available controls. The price sheet at /v1/catalog/rates does not include thinking choices.

FieldMeaning
supported_effortsThe model's native enabled levels, when it has levels. A toggle-only model omits this field.
default_effortThe default level, or none when a level-based model defaults to off. Omitted for toggle-only models.
default_enabledWhether thinking is on by default.
mandatoryWhether thinking must stay on; if true, do not offer Off.

An absent reasoning object means no declared thinking controls. Use the metadata rather than assuming every model supports the same efforts or starts at Medium. Models shows the current choices and defaults.

Output limits and structured responses

Chat and text completions accept max_completion_tokens as an alias of max_tokens. Send either name; if both are present, their values must agree, including whether they are null. A conflict is refused with 400 before a credit hold.

Chat completions accept response_format with type set to text, json_object or json_schema. For a JSON Schema, also supply json_schema with a name and a schema object; description and strict are optional. The schema reaches the engine unchanged.

Constrained formats use only serving recipes that support them, including on a retry or a spill to another recipe. If none can honour the requested format, the request is refused with response_format_unsupported before a credit hold. The model list reports supports_response_format under shardio; the model detail page lists it among supported parameters.

Token usage in responses

A chat or text completion reports usage with prompt_tokens, completion_tokens and total_tokens: the counts you are billed for. A streamed request gets the same object in one final chunk when it sends "stream_options": {"include_usage": true}.

completion_tokens includes thinking. When the model thought, usage.completion_tokens_details.reasoning_tokens gives the thinking share of it. It is already part of completion_tokens, not an extra charge, and it equals the thinking tokens shown for the request in your usage history. When the model did not think, completion_tokens_details is absent. On a model with a cache-read price, usage.prompt_tokens_details.cached_tokens gives the prompt tokens billed at that price.

Exporting request usage

GET /v1/usage?period=2026-10&limit=200 returns retained request metadata and costs for a UTC calendar month. period defaults to the current month. limit is from 1 to 200; pass a returned next_cursor as cursor to read the next page of the same month.

Any valid inference key may read the whole account's request history, including requests made with sibling or deleted keys. The export never includes another account, prompts or completions. It uses the ordinary request rate limit but does not reserve credit, so an account can export usage at a zero balance.

detail_from is the retention boundary. partial: true means the requested month starts before that boundary; this is not a complete billing statement. Use the account's statements and invoices for settled billing history. Invalid month, page limit and cursor values return 400 with invalid_period, invalid_limit and invalid_cursor, respectively.

Marketplace model document

GET /v1/marketplaces/openrouter/models returns the OpenRouter provider model schema, separate from the OpenAI-shaped /v1/models. Its output modality names the API the model actually serves: text, embeddings or decisions. A decision model does not advertise text generation, streaming, sampling parameters or tool calling; its charge is declared on its text input.

Request ids and per-request costs

Every response to a request that reaches a model carries an Inference-Id header with that request's id, such as req_4mZq8vN2xKpL. A streamed response sends it before the first chunk. It is the same id your usage export and Activity show, and a chat completion's id is the same value with a chatcmpl- prefix in place of req_.

POST /v1/billing/costs with {"requestIds": ["req_…", …]} returns {"requests": [{"requestId": "req_…", "costNanoUsd": 1234000}, …]}: the cost of each request your account made, in nano-USD (10⁻⁹ USD, so one cent is 10,000,000). Send up to 10,000 ids at a time. An id that is unknown, belongs to another account, is more than two days old or has not settled yet is left out, so ask again later; the same id always answers the same cost. Marketplaces that bill each request they route, such as Hugging Face, call it to learn what to charge. Like the usage export, it uses the ordinary request rate limit and needs no credit.

Prices in the model list

Each model in /v1/models carries context_length, the context window in tokens a request may use now (the same figure as shardio.context_limit), and pricing with input and output in US dollars per million tokens, the fields marketplaces read. The exact integer prices, in microdollars per million tokens, stay under shardio (price_in_micro_1m, price_out_micro_1m, price_cache_read_micro_1m); a model without an input price has no pricing object.

Routes

Every path is also served under /openai/v1, as under /v1.

POST /v1/billing/costs

Look up request costs

The cost of each request this API key's account made, by the id the Inference-Id response header named, in nano-USD (10^-9 USD). An id that is unknown, another account's, older than two days, or not settled yet is left out; ask again later. The same id always answers the same cost. Hugging Face Inference Providers calls this to bill the requests it routes. It uses the ordinary request rate limit but needs no credits.

Responses

StatusContentDescription
200application/jsonOne cost per request id whose cost is known.

GET /v1/catalog/rates

List prices

The public price sheet: every model in the public catalog with its prices per million tokens. Needs no API key; a response may be cached for five minutes.

Responses

StatusContentDescription
200application/jsonEach model's prices, context limit and status, with payout_share: the host share when every model has the same one, otherwise null.

POST /v1/chat/completions

Create a chat completion

OpenAI-compatible chat completion. Set stream to receive the reply as server-sent events.

Request body

An OpenAI chat completion request. ChatCompletionRequest, application/json, required.

FieldTypeRequiredDescription
chat_template_kwargsChatTemplateOptions or nullno
conversation_idstring or nullno maxLength: 128
enable_thinkingboolean or nullno
frequency_penaltynumber or nullno minimum: -2 maximum: 2
max_tokensinteger or nullnoMaximum total output tokens, including thinking. Also accepted as max_completion_tokens; if both names are sent, their values must agree. minimum: 1
messagesarray of ChatMessageyes minItems: 1
modelstringyes
presence_penaltynumber or nullno minimum: -2 maximum: 2
preserve_thinkingboolean or nullno
reasoningReasoningOptions or nullno
reasoning_effortstring or nullno minLength: 1 maxLength: 32
response_format(TextResponseFormat or JsonSchemaResponseFormat) or nullno
seedinteger or nullno minimum: -9223372036854776000 maximum: 9223372036854776000
stopstring or array of string or nullno minLength: 1 maxLength: 256 minItems: 1 maxItems: 4
streambooleanno default: false
stream_optionsStreamOptions or nullno
temperaturenumber or nullno minimum: 0 maximum: 2
tool_choicestring or object or nullno
toolsarray of object or nullno maxItems: 128
top_pnumber or nullno minimum: 0 maximum: 1

Responses

StatusContentDescription
200application/json, text/event-streamA chat.completion object. With stream: true, a text/event-stream of chat.completion.chunk events ending with data: [DONE]. With stream_options.include_usage, a usage chunk comes just before [DONE]. Lines starting with : keep an idle stream open. A failure after the stream has started arrives as a last event carrying an error object, with no [DONE].

POST /v1/completions

Create a completion

OpenAI-compatible text completion of a prompt. Set stream to receive the text as server-sent events.

Request body

An OpenAI completion request. CompletionRequest, application/json, required.

FieldTypeRequiredDescription
conversation_idstring or nullno maxLength: 128
frequency_penaltynumber or nullno minimum: -2 maximum: 2
max_tokensinteger or nullnoMaximum total output tokens, including thinking. Also accepted as max_completion_tokens; if both names are sent, their values must agree. minimum: 1
modelstringyes
presence_penaltynumber or nullno minimum: -2 maximum: 2
promptstring or array of string or array of objectno default: ""
seedinteger or nullno minimum: -9223372036854776000 maximum: 9223372036854776000
stopstring or array of string or nullno minLength: 1 maxLength: 256 minItems: 1 maxItems: 4
streambooleanno default: false
stream_optionsStreamOptions or nullno
temperaturenumber or nullno minimum: 0 maximum: 2
top_pnumber or nullno minimum: 0 maximum: 1

Responses

StatusContentDescription
200application/json, text/event-streamA text_completion object. With stream: true, a text/event-stream of text_completion events ending with data: [DONE]. With stream_options.include_usage, a usage chunk comes just before [DONE]. Lines starting with : keep an idle stream open. A failure after the stream has started arrives as a last event carrying an error object, with no [DONE].

POST /v1/decisions

Ask a decision (OpenAI Decisions)

OpenAI's Decisions API. It asks the same decision models as the System One route.

Request body

An OpenAI Decisions request. The body may be compressed with Content-Encoding: gzip or zstd. DecisionsRequest, application/json, required.

FieldTypeRequiredDescription
inputstring or arrayyes
modelstringyes
questionsarray of (PredicateQuestion or OpenAIChoiceQuestion or OpenAIScoreQuestion)yes minItems: 1 maxItems: 64

Responses

StatusContentDescription
200application/jsonThe model and one answer per question, in question order, with input token usage. Output is free: output_tokens is always 0.

POST /v1/embeddings

Create embeddings

OpenAI-compatible embeddings of one or more texts.

Request body

An OpenAI embeddings request. EmbeddingsRequest, application/json, required.

FieldTypeRequiredDescription
inputstring or array of stringyes
modelstringyes

Responses

StatusContentDescription
200application/jsonA list of embedding objects, one per input in input order, with the input's token usage.

GET /v1/models

List models

OpenAI-compatible list of the models this API key can call, with Shardio's details under shardio: prices, context limit, availability, measured speed and tool support.

Responses

StatusContentDescription
200application/jsonA list of model objects.

POST /v1/systemone

Ask a decision (System One)

TypeSafe's System One API, so a TypeSafe SDK works with Shardio's base URL alone. It asks the same decision models as the OpenAI-dialect decisions route.

Request body

A System One request. The body may be compressed with Content-Encoding: gzip or zstd. SystemOneRequest, application/json, required.

FieldTypeRequiredDescription
assetsobject or nullno
imagesarray or nullno
modelstringyes
questionsmap of (NoulQuestion or ChoiceQuestion or ScoreQuestion)yes minProperties: 1 maxProperties: 64
statestring or object or arrayyes

Responses

StatusContentDescription
200application/jsonThe model and one answer per question, keyed by question id, with input token usage. Output is free: output_tokens is always 0.

GET /v1/usage

Export account request usage

Read retained request metadata and costs for your account with an inference key. Includes requests made with other or deleted keys on the same account, never request or response content. This read uses the ordinary request rate limit but needs no credits. detail_from and partial describe retained history, not a complete billing statement.

Responses

StatusContentDescription
200application/jsonA page of request metadata, its next cursor and retention coverage.

Schemas

ChatMessage

FieldTypeRequiredDescription
contentstring or array of objectno default: ""
role"system" | "assistant" | "user" | "tool" | "developer"yes
tool_call_idstring or nullno
tool_callsarray of object or nullno

ChatTemplateOptions

FieldTypeRequiredDescription
enable_thinkingboolean or nullno
preserve_thinkingboolean or nullno
reasoning_effortstring or nullno minLength: 1 maxLength: 32

ChoiceOption

FieldTypeRequiredDescription
descriptionstring or nullno
valuestring or booleanyes

ChoiceQuestion

FieldTypeRequiredDescription
criteriamap of (string or object or array or null)yes minProperties: 1 maxProperties: 255
instructionsstring or object or array or nullno
type"choice"yes

JsonSchemaResponseFormat

FieldTypeRequiredDescription
json_schemaResponseJsonSchemayes
type"json_schema"yes

Level

FieldTypeRequiredDescription
descriptionstring or nullno
labelstringyes

NoulCriteria

FieldTypeRequiredDescription
falsestring or object or array or nullno
truestring or object or array or nullno

NoulQuestion

FieldTypeRequiredDescription
criteriaNoulCriteria or nullno
instructionsstring or object or array or nullno
type"noul"yes

OpenAIChoiceQuestion

FieldTypeRequiredDescription
choicesarray of ChoiceOptionyes minItems: 2 maxItems: 255
instructionsstringyes
namestring or nullno
type"choice"yes

OpenAIScoreQuestion

FieldTypeRequiredDescription
instructionsstringyes
levelsarray of Levelyes minItems: 1 maxItems: 10
namestring or nullno
type"score"yes

PredicateQuestion

FieldTypeRequiredDescription
instructionsstringyes
namestring or nullno
type"predicate"yes

ReasoningOptions

FieldTypeRequiredDescription
effortstring or nullno minLength: 1 maxLength: 32
enabledboolean or nullno

ResponseJsonSchema

FieldTypeRequiredDescription
descriptionstring or nullno
namestringyes minLength: 1 maxLength: 64
schemaobjectyes
strictboolean or nullno

ScoreQuestion

FieldTypeRequiredDescription
criteriaarray of (string or object or array)yes minItems: 1 maxItems: 10
instructionsstring or object or array or nullno
type"score"yes

StreamOptions

FieldTypeRequiredDescription
include_usagebooleanno default: false

TextResponseFormat

FieldTypeRequiredDescription
type"text" | "json_object"yes