Skip to main content
Use Cases
Keep an existing Anthropic SDK codebase and point it at Orq.ai with a single base_url change; streaming, tool use, and multimodal input keep working unchanged.
Mark the system prompt or reference documents with cache_control so repeat calls and follow-up turns read them from cache instead of paying full price.
Change the model value to any provider/model_id in the AI Gateway catalog, from Claude to OpenAI and other providers, without swapping SDKs.
Fallbacks, budgets, guardrails, and traces apply to every Anthropic SDK call routed through the gateway.

Overview

The AI Gateway is a routing layer that proxies one API to 300+ models across providers, adding fallbacks, budgets, guardrails, and traces; see the quick start. It exposes an Anthropic-compatible endpoint at https://api.orq.ai/v3/anthropic. The Anthropic SDK appends /v1/messages to the base URL automatically, so existing Anthropic code runs against Orq.ai with no other changes. Requests authenticate with an Orq.ai API key and run through the same pipeline as the OpenAI-compatible API, so fallbacks, budgets, guardrails, and traces all apply. Prompt caching on Claude models is opt-in via cache_control breakpoints, exactly as in the native Anthropic API.

Quick Start

Before you start: complete the AI Gateway quick start once. It walks through creating an account at my.orq.ai, connecting a provider (BYOK) with an Anthropic API key, and creating an Orq.ai API key. Then set the key in the environment:
Set the base URL to https://api.orq.ai/v3/anthropic and send a messages request with an Orq.ai API key. cURL requests use the full path shown below; SDKs set baseURL to https://api.orq.ai/v3/anthropic and the client appends /v1/messages automatically.

Supported Endpoints

All routes are relative to the base URL https://api.orq.ai/v3/anthropic and mirror the Anthropic Messages API request and response formats.
count_tokens returns {"input_tokens": 0} when the resolved model does not support token counting, which is indistinguishable from a real zero-token result. If the count is required, verify the model supports counting before relying on it.

Authentication

Authenticate with the Orq.ai API key in either header:
  • Authorization: Bearer $ORQ_API_KEY
  • x-api-key: $ORQ_API_KEY (the header the Anthropic SDK sends by default)
The Anthropic SDK works unmodified: set ANTHROPIC_API_KEY to an Orq.ai key and ANTHROPIC_BASE_URL to https://api.orq.ai/v3/anthropic. Alternatively, pass the constructor parameters shown in the Quick Start (apiKey/baseURL in TypeScript, api_key/base_url in Python).
To learn more about Orq.ai API keys, see API Keys.

Model Naming

Use the provider/model_id format from the AI Gateway catalog:
  • anthropic/claude-sonnet-5 for Claude models.
  • Any other provider prefix, for example openai/gpt-5.6-sol, routed through the same Anthropic-compatible endpoint.
GET /v1/models returns some models as native IDs without the provider prefix (for example claude-sonnet-4-6). Those IDs also resolve on this endpoint; the catalog provider/model_id form is unambiguous. The same catalog applies to every AI Gateway API, including /v3/router and the Responses API. Browse every available model in Supported Models.

Gateway Features

Because requests run through the same pipeline as the router, the following AI Gateway features apply to Anthropic SDK calls:

Prompt Caching

Prompt caching is opt-in: add a cache_control object to a content block to mark a cache breakpoint, the end of a cacheable prefix. Breakpoints pass through unchanged on this endpoint, including multi-turn and streaming requests.

Prompt caching

Supported cache_control values, TTLs, block types, minimum token thresholds, and usage reporting.
Cache writes and reads appear in the response usage as cache_creation_input_tokens (write) and cache_read_input_tokens (read), the native Anthropic shape. cache_control on a non-Anthropic model is ignored, not rejected.

Multi-turn example

Mark the system prompt with a breakpoint, then send a follow-up turn with the same prefix to read from cache. The system text below is abbreviated; use a prefix above the provider minimum token threshold for the cache read to appear. The TypeScript and Python tabs reuse the client from the Quick Start.
The second call sends the identical system prefix with a new user turn. When the marked prefix is above the provider minimum token threshold, the response reports cache_read_input_tokens greater than zero instead of paying full price for the system prompt.

Manual vs Automatic Prompt Caching

How prompt caching is enabled depends on the endpoint and the provider: Use manual breakpoints when the request has a long stable prefix and the cache boundary matters. The Responses API’s top-level cache_control marks the last cacheable block automatically; it does not allow multiple breakpoints. OpenAI and Gemini 2.0+ cache automatically, and providers that cache automatically ignore cache_control, so the two approaches do not conflict. For the full comparison, see Prompt caching.