Skip to main content

AI Gateway

Fallbacks and advanced options

Fallback models, reasoning, plugins, web search, and other advanced options.

These are advanced options the pre.dev AI API supports on top of the standard chat completion fields. You choose the model; pre.dev chooses how to serve it.

Fallback models

Send models instead of a single model. The gateway tries each in order, and the response reports which one answered.

{
  "models": ["anthropic/claude-sonnet-5", "openai/gpt-6-luna", "deepseek/deepseek-v4.1-flash-1017"],
  "route": "fallback",
  "messages": [{ "role": "user", "content": "Summarize the plot of Dune in two sentences." }]
}

You pay for the model that actually answered, at its own price. Read model in the response, or the by_model rows in usage, to see where traffic landed.

Reasoning

reasoning (an object) and reasoning_effort (a string) control thinking on models that support it. Reasoning tokens are billed as output tokens.

{
  "model": "anthropic/claude-sonnet-5",
  "reasoning": { "effort": "medium" },
  "messages": [{ "role": "user", "content": "Is 9973 prime? Show your reasoning briefly." }]
}

Many models reason by default. For short answers, pass reasoning: { "enabled": false } or keep max_tokens large enough for the thinking and the answer.

plugins accepts web, file-parser, response-healing, and context-compression. web_search_options tunes the web plugin, and a model id ending in :online turns web search on. Plugin costs are part of the call’s charge.

{
  "model": "openai/gpt-6-luna",
  "plugins": [{ "id": "web" }],
  "web_search_options": { "search_context_size": "low" },
  "messages": [{ "role": "user", "content": "What changed in the latest Node.js LTS release?" }]
}

Other supported fields

FieldPurpose
transformsPrompt transforms, such as compressing a long conversation to fit the context
predictionPredicted outputs
verbosityResponse length hint
session_idGroup related requests under one session
userEnd-user identifier; pre.dev prefixes it with an identifier for your workspace

If you send user, keep it stable per end user so abuse reports can be attributed.

Was this page helpful?

On this page