API Reference
Tangle Router exposes an OpenAI-compatible REST API. Response formats depend on the operation: chat returns JSON or SSE, speech returns audio bytes, and video content returns media. Image edits accept multipart/form-data; transcription accepts JSON with base64 audio in input_audio.data and its format in input_audio.format. Read the OpenAPI contract for typed operations.
Search guides and API reference.
Base URL
https://router.tangle.tools/v1Authentication
Pass your API key in the Authorization header:
Authorization: Bearer sk-tan-your-key-herePrompt Caching
Prompt caching is on by default. Agents, audits, and RAG workloads with repeated prefixes get provider-native cache reads without changing SDKs.
const completion = await client.chat.completions.create({
model: 'anthropic/claude-sonnet-4-6',
messages: [
{ role: 'system', content: longStableSystemPrompt },
{ role: 'user', content: 'Use the same context again.' },
],
providerOptions: {
gateway: {
caching: 'auto',
cacheControl: { enabled: true, ttl: '1h' },
},
},
})X-Tangle-Prompt-Cachemiss, read, write, or read_write
usage.prompt_cachetokens read, tokens written, and USD savings
Opt out per request with providerOptions.gateway.caching = false.
Blueprint Routing
Route requests to Tangle operators running specific Blueprints. Pass as headers or in the request body.
X-Tangle-Routing"operator" | "provider" | "auto" — control routing target
X-Tangle-BlueprintOn-chain Blueprint ID (uint) — route to operators under this Blueprint
X-Tangle-ServiceOn-chain service instance ID (uint) — route to a specific service
X-Tangle-OperatorOperator address (0x...) or slug — pin to a specific operator
Endpoints
/v1/chat/completionsCreate a chat completion. Returns JSON unless stream: true requests SSE.
Request fields (42)
modelstringrequiredmessagesobject[]requiredstreambooleanOnly true requests SSE. Omitted or false returns a JSON completion.
temperaturenumbermax_tokensintegertoolsobject[]tool_choicenone | auto | required | objectAny other string returns 400 invalid_tool_choice; objects are checked by the provider.
parallel_tool_callsbooleanresponse_formattext | json_object | json_schemaStructured output.
top_pnumberstopstring | string[]seedintegernintegerpresence_penaltynumberfrequency_penaltynumberlogit_biasobjectlogprobsbooleantop_logprobsintegeruserstringmetadataobjectstorebooleanstream_optionsobjectRouter requests usage on every stream so it can bill; the final chunk carries usage.
service_tierflex | priorityAny other value returns 400 invalid_service_tier.
reasoning_effortstringreasoningobjectthinkingobjectAnthropic extended thinking.
max_completion_tokensinteger0 is accepted only for Anthropic prompt-cache pre-warm requests; other models need at least 1.
modalitiesstring[]audioobjectpredictionobjectsystemanyAnthropic-style system prompt.
cache_controlobjectProvider prompt-cache control, sanitized per provider.
prompt_cache_keystringprompt_cache_retentionstringprompt_cache_isolation_keystringsession_idstringmodelsstring[]Router: fallback models, tried in order.
providerobjectRouter: provider routing preferences (order, only, ignore, max_price, data_collection, ...).
gatewayobjectRouter: gateway options.
providerOptionsobjectRouter: providerOptions.gateway carries gateway options, including byok and maxPrice.
pluginsobject[]Router: server plugins such as web search.
transformsstring[]
400 Invalid request. error.code identifies the cause; codes include invalid_json, invalid_model, model_not_found, model_not_allowed, invalid_message_role, invalid_tool_choice, invalid_service_tier, invalid_require_model, unsupported_parameters, conflicting_options, max_price_exceeded, no_zdr_providers, zdr_extensions_not_supported, no_train_extensions_not_supported, model_requires_responses_for_tools, model_requires_reasoning_effort_none_for_tools, model_requires_audio_speech_endpoint, preset_not_found, guardrail_blocked, byok_credential_unavailable, byok_operator_conflict, invalid_execution_correlation.
/v1/responsesOpenAI Responses API — agentic, tool-using completions.
Request fields (9)
modelstringrequiredinputstring | object[]instructionsstringstreambooleantrue returns text/event-stream; omitted or false returns JSON.
toolsobject[]Function tools pass through; Router-run server tools (web search, fetch, image generation) are executed by Router.
tool_choiceanytextobjectOutput format, including json_schema structured output.
previous_response_idstringservice_tierflex | priorityRequested provider service tier. Any other value returns 400 invalid_service_tier.
400 Invalid request. error.code identifies the cause; codes include invalid_json, missing_model, invalid_service_tier, invalid_execution_correlation, no_train_extensions_not_supported, zdr_extensions_not_supported, execution_correlation_required and model_not_allowed (key allow-list), and previous_response_not_supported for chat-served Responses requests. Chat-served requests can also return the chat completions error codes.
/v1/messagesAnthropic Messages API — Claude-compatible completions.
Request fields (7)
modelstringrequiredmessagesobject[]systemstring | object[]max_tokensintegerstreambooleantrue returns text/event-stream; omitted or false returns JSON.
toolsobject[]service_tierflex | priorityRequested provider service tier. Any other value returns 400 invalid_service_tier.
400 Invalid request. error.code identifies the cause; codes include invalid_json, missing_model, invalid_service_tier, invalid_execution_correlation, no_train_extensions_not_supported, zdr_extensions_not_supported, execution_correlation_required and model_not_allowed (key allow-list), and previous_response_not_supported for chat-served Responses requests. Chat-served requests can also return the chat completions error codes.
/v1/modelsDiscover model IDs, capabilities and pricing across providers and operators.
/v1/models/countCount catalog models by output modality.
Parameters (1)
output_modalitiesstring (query)Comma-separated list of text, image, audio, embeddings, or all. Defaults to text.
400 Unknown modality (invalid_output_modalities).
/v1/providersList providers that serve catalog models, with their data centres and policies.
/v1/byokList encrypted bring-your-own-key provider credentials.
/v1/byokCreate an encrypted bring-your-own-key provider credential.
/v1/byok/00000000-0000-4000-8000-000000000000Get a bring-your-own-key provider credential by ID.
/v1/workspacesList enterprise workspaces for the management key.
/v1/workspacesCreate an enterprise workspace.
/v1/workspaces/defaultGet a workspace by ID or slug.
/v1/organization/membersList organization members available to workspaces.
/v1/observability/destinationsList workspace-scoped observability destinations.
/v1/observability/destinationsCreate an encrypted observability destination.
/v1/observability/destinations/00000000-0000-4000-8000-000000000000Get an observability destination by ID.
/v1/presets/default/chat/completionsCreate or version a reusable chat-completions preset.
/v1/embeddingsGenerate text embeddings.
/v1/rerankRerank documents against a query.
/v1/images/generationsGenerate images from text prompts.
/v1/images/editsEdit or inpaint images with a prompt (multipart/form-data).
/v1/audio/speechGenerate speech from text (TTS).
/v1/batchSubmit a batch of requests for parallel processing.
/v1/batchRetrieve a caller-scoped batch with the required ?id= query parameter.
/v1/operatorsList active operators on the network.