API reference

API reference

Choose a wire format, authenticate requests, and inspect routing headers.

Use https://unused.market/v1 as the OpenAI-compatible base URL. The API Keys quickstart shows the exact gateway URL for your account. Anthropic SDKs take the host https://unused.market and append /v1/messages themselves.

Endpoints

MethodRoutePurpose
POST/v1/chat/completionsOpenAI-format text, tools, images, reasoning and structured output
POST/v1/messagesAnthropic-format messages and content blocks
POST/v1/messages/count_tokensProvider token count or an estimate
GET/v1/modelsUsable models, filtered by key and routing restrictions

The public gateway does not expose /v1/responses, Realtime, Batch or Assistants. Client format and provider format are independent: the gateway converts supported features in either direction. Individual offers can impose additional feature limits. See Models.

Authenticate every request

Send one of these headers, using the key you created in API Keys:

Bearer authentication
Authorization: Bearer sk-unused-...
Alternative authentication
x-api-key: sk-unused-...

sk-unused-... is a documentation placeholder. Replace it with the complete revealed key; do not edit its prefix. If you send both headers, a recognized Bearer value in Authorization takes precedence over x-api-key. JSON requests also need Content-Type: application/json.

Inspect response headers

Prop

Type

Send anthropic-version: 2023-06-01 with Anthropic clients. On GET /v1/models, the presence of anthropic-version selects the Anthropic-shaped response. Without it, the response uses OpenAI's object: "list" envelope. A successful token count returns input_tokens; it does not create an inference charge or a successful request-history row.

Set an output budget

On Chat Completions, set max_completion_tokens or max_tokens. If both are present, max_completion_tokens wins. If neither is present, the gateway uses the model's maximum output allowance, which can create a larger credit hold. On Messages, max_tokens is required. The count-tokens route supplies its own one-token validation budget.

Your estimated input plus output budget must fit the model's context window. See credits and holds. A request routed through a Codex subscription has an effective minimum output budget of 16 tokens; its final charge still uses actual usage.

Stream a response

Set stream: true to receive server-sent events. OpenAI clients can add stream_options: { "include_usage": true }. Consume the entire stream, including usage and termination events, and handle an error event even after a successful HTTP status.

Before response bytes are sent, the gateway can try another offer. Once bytes are sent, it does not switch offers: it sends an error event when the connection still allows it. A disconnected or non-reading client can instead lose the connection. A partial response can have recorded usage and a charge. See errors before retrying.

Unsupported options

The OpenAI parser rejects n other than 1, logprobs, top_logprobs, logit_bias, top-level audio, message-level audio, and non-text entries in modalities. System and developer content must be text. Only function tools and text/image content types defined in the generated schema are supported.

This is a compatibility surface, not a promise that every field of either vendor API works. Do not infer support from an unrelated field being accepted. Model and upstream capabilities still apply. Preserve returned reasoning blocks and opaque signatures through tool turns; changing them can break the next provider request.

Read the schema

The endpoint pages below are generated from the runtime OpenAPI request schemas. Download the public gateway schema. The runtime document currently omits response schemas, so examples and the error guide are verified separately against code and local fake-upstream requests.

On this page