Overview
In addition to our purpose-built code models, we host our set of preferred open-weight models for coding tasks. You can hit these models directly through our OpenAI-compatible API. For discounted reserve rates, reach out to info@relace.ai. All hosted models are served fromhttps://models.relace.ai and authenticate with your regular Relace API key — no separate setup, and any OpenAI SDK works by pointing it at our base URL.
Prerequisites
1
Call Chat Completions
Send requests to Tool calling, JSON mode, structured outputs, and the standard sampling parameters (
/v1/chat/completions with the model ID of your choice. The endpoint is OpenAI-compatible, so you can use the OpenAI SDK directly.temperature, top_p, stop, etc.) work as they do with any OpenAI-compatible provider.2
Stream Responses
Set
stream: true to receive tokens as they are generated. Token usage is always reported in the final chunk of the stream.Anthropic-Compatible API
The same models are also served at/v1/messages in the Anthropic Messages dialect, so an Anthropic SDK works by pointing it at https://models.relace.ai. Content blocks, tool use, streaming, and extended thinking map onto the same model features as Chat Completions; pick whichever dialect your client already speaks.
usage.cache_read_input_tokens, and metadata.user_id plays the role of prompt_cache_key for session affinity.
Prompt Caching and Session Affinity
Prompt caching is automatic: when a request’s prompt shares a prefix with a recent request, the shared tokens are served from cache and billed at the Cached Input rate above. There are no cache breakpoints to place. Cache hits are reported inusage.prompt_tokens_details.cached_tokens.
Caches are per server, so hit rates depend on requests from the same session routing to the same server. By default, requests are routed on a fingerprint of the conversation’s opening messages. To control routing explicitly, set prompt_cache_key (the same parameter as OpenAI’s): requests with the same key are routed to the same server, even when their prompts differ.
- Use a stable value per conversation or session, such as a session ID or user ID.
- Don’t use a single key for all of your traffic; that concentrates it on one server and lowers your hit rate.
- Affinity is best-effort: under failover or capacity pressure, a request may be served by a different server.