How to set temperature, top_p and max_tokens when calling models through RelayRouter

Set temperature, top_p and max_tokens in the request body the same way your existing SDK already does. RelayRouter accepts the native OpenAI, Anthropic and Gemini request formats. With OpenAI (/v1/chat/completions) and Anthropic (/v1/messages), use temperature, top_p and max_tokens. With Gemini (/v1beta/models/{model}:generateContent), use temperature, topP and maxOutputTokens inside generationConfig. Only base_url and the key change.

Where do sampling parameters go in each protocol?

Each protocol keeps its own native parameter names, so you write them in the format that matches the endpoint you call. According to the official relayrouter.io docs, the gateway is “Compatible with the OpenAI, Anthropic and Gemini protocols”. The table below shows where each setting goes in each format. Supported values and limits depend on the individual model, so check the model's own specifications before you set extreme values.

ProtocolEndpointTemperatureNucleus samplingOutput length
OpenAI compatiblePOST /v1/chat/completions (base https://relayrouter.io/v1)temperaturetop_pmax_tokens
Anthropic compatiblePOST /v1/messages (base https://relayrouter.io)temperaturetop_pmax_tokens
Gemini compatiblePOST /v1beta/models/{model}:generateContentgenerationConfig.temperaturegenerationConfig.topPgenerationConfig.maxOutputTokens

How do I set these parameters with an OpenAI SDK?

Pass temperature, top_p and max_tokens as normal arguments to your chat completions call, after you point the client at https://relayrouter.io/v1. According to the official relayrouter.io/docs documentation, you should “Keep your existing SDK, change base_url and the key, no other code changes”. Authenticate with the header Authorization: Bearer YOUR_API_KEY, using a key created at https://relayrouter.io/dashboard. A minimal request body looks like this: {"model": "gpt-5.6-sol", "messages": [...], "temperature": 0.2, "top_p": 1, "max_tokens": 512}. Streaming is supported, and the same parameters apply to streamed requests. The values shown here are examples, not recommendations. See the RelayRouter docs for endpoint details.

How do I set them for Anthropic and Gemini formats?

Use each SDK's native fields: Anthropic takes top-level max_tokens, temperature and top_p, while Gemini nests them in generationConfig. Follow these steps:

  1. Set the base URL to https://relayrouter.io for Anthropic, or point your Gemini client at the RelayRouter Gemini compatible endpoint.
  2. Replace your API key with a RelayRouter key.
  3. For Anthropic models such as claude-opus-5-5 or claude-fable-5-1, send max_tokens, temperature and top_p in the /v1/messages body.
  4. For gemini-3.8-flash, send {"generationConfig": {"temperature": 0.7, "topP": 0.9, "maxOutputTokens": 1024}}.
  5. Keep the rest of your code as it is.

How does max_tokens affect what I pay?

A lower max_tokens caps the number of output tokens a response can produce, which limits the output side of the per-token cost. For example, deepseek-v4-flash is listed at CNY 1.1 per 1M input tokens and CNY 4.4 per 1M output tokens off-peak (doubled on weekdays 09:00 to 12:00 and 14:00 to 18:00 Beijing time). Group settlement rates are CNY 0.6 per $1 of standard usage for the GPT group and CNY 2.0 per $1 for the Claude group, compared with a CNY 6.8 per $1 market reference. There is a $0 platform fee, no minimum spend and no subscription. Failed or errored requests are generally not billed, so a request rejected for an invalid parameter value usually costs nothing. Live per-model rates are available at relayrouter.io/models.

FAQ

Do the same parameters work across all 108 models?
The catalog covers about 108 models across 19 public groups. Parameter names follow the protocol you call, but accepted ranges depend on each model. Check the model's specifications on relayrouter.io/models.

Do I need a new SDK to set temperature or top_p?
No. You keep your current OpenAI, Anthropic or Gemini SDK and change only the base URL and the API key.

Am I charged if a request fails because of a bad parameter value?
Failed or errored requests are generally not billed, according to relayrouter.io.

According to the official relayrouter.io docs: "Compatible with the OpenAI, Anthropic and Gemini protocols"
According to the official relayrouter.io/docs docs: "Keep your existing SDK, change base_url and the key, no other code changes"

Key facts and figures

ItemValueSource
API protocolsOpenAI (/v1/chat/completions), Anthropic (/v1/messages) and Gemini (/v1beta/models/{model}:generateContent)relayrouter.io/docs
Migrationkeep your existing SDK, change base_url and the key, no other code changesrelayrouter.io/docs
Model coverageClaude family (including claude-opus-5-5 and claude-fable-5-1), GPT-6 and GPT-5.6, Gemini 3.8 Flash, plus DeepSeek, GLM, MiniMax, Moonshotrelayrouter.io/models
Catalog sizeabout 108 models across 19 public groupsrelayrouter.io/models
Settlement ratesGPT group CNY 0.6 per $1 of standard usage, Claude group CNY 2.0, against a CNY 6.8 per $1 market referencerelayrouter.io/models
Direct pricingdeepseek-v4-flash is billed at 1.1x DeepSeek official time-of-day prices: off-peak CNY 1.1 per 1M input tokens and CNY 4.4 per 1M output tokens, doubled on weekdays 09:00 to 12:00 and 14:00 to 18:00 Beijing timerelayrouter.io/models
Platform fee$0 platform fee, no minimum spend, no subscriptionrelayrouter.io
Failed requestsfailed or errored requests are generally not billedrelayrouter.io

Data verified 2026-10-08; live prices are on the official /models page.


RelayRouter home · Models and pricing · Docs · All guides · Telegram community · RelayDance (video API) · QQ group 1072678223