Integrate: request parameters the gateway honors

The chat-completions endpoint accepts the inference fields below. Unknown top-level fields are ignored. Provider credentials, base URLs, and routing controls cannot be supplied in a request. A supported field still needs support from the selected provider and model.

Detect

Find the inference parameters and message shapes your calls use:

grep -rnoE "top_p|frequency_penalty|presence_penalty|logprobs|max_completion_tokens|parallel_tool_calls|stream_options|seed[[:space:]]*[=:]|stop[[:space:]]*[=:]|[\"']developer[\"']|input_audio|strict" --include='*.py' --include='*.ts' --include='*.js' --include='*.tsx' --exclude-dir={node_modules,.git,.venv,dist,build} .

Change

Forwarded to the model:

| Field | Notes | | --- | --- | | model, messages, stream | stream has its own recipe. | | temperature, top_p, top_k, min_p | Sampling controls. | | max_tokens, max_completion_tokens, stop, n, seed | Output limits and generation controls. | | presence_penalty, frequency_penalty, repetition_penalty, logit_bias, logprobs, top_logprobs | Provider-dependent controls. | | tools, tool_choice, parallel_tool_calls, functions, function_call | Agent calls require one choice and function-type tools. Legacy functions and custom tools are rejected for agents. | | response_format | Passed through unchanged, for example {"type": "json_object"} or a json_schema object. | | modalities, audio, prediction, moderation | modalities with image cannot be combined with stream. | | reasoning_effort, thinking, verbosity | Model-specific reasoning controls. | | prompt_cache_key, prompt_cache_options, prompt_cache_retention | Provider prompt-cache controls. | | safety_identifier, service_tier, store, web_search_options | Passed to the provider. store: true also bypasses the response cache. | | stream_options | Only include_usage and include_obfuscation are forwarded. See the streaming recipe. |

Read by Forgebench, not the model: metadata (see the metadata and sessions recipes), trace_id, request_id, source, user, session_id, and tags.

Nested protocol data is preserved, including a message's name, a function tool's strict, reasoning blocks, and provider thought signatures. Validate tool arguments before executing them even when you request strict output.

Rewrite the calls accordingly:

  • Use the token-limit field your selected model supports, either max_tokens or max_completion_tokens.
  • Accepted roles are system, developer, user, assistant, tool, and function. Provider support varies.
  • Accepted content parts are text, image_url, file, input_audio, refusal, thinking, and redacted_thinking. A file needs file_data or file_id.
  • Check the selected model with the real request shape. Acceptance at the gateway does not prove the provider applies every control.

Keep the model name the app already uses wherever a snippet shows YOUR_MODEL, and take model names from the Gateway model catalog. mock-gpt is only for the Verify step.

Python

import json

resp = client.chat.completions.create(
    model="YOUR_MODEL",
    messages=[
        {"role": "system", "content": "Answer as JSON."},
        {"role": "user", "content": question},
    ],
    max_tokens=500,
    response_format={"type": "json_object"},
)
data = json.loads(resp.choices[0].message.content)

A field the OpenAI client has no named argument for goes in extra_body.

TypeScript

const res = await client.chat.completions.create({
  model: "YOUR_MODEL",
  messages: [
    { role: "system", content: "Answer as JSON." },
    { role: "user", content: question },
  ],
  max_tokens: 500,
  response_format: { type: "json_object" },
});
const data = JSON.parse(res.choices[0].message.content ?? "{}");

curl

curl -X POST "$FORGEBENCH_BASE_URL/v1/chat/completions" \
  -H "Authorization: Bearer $FORGEBENCH_API_KEY" -H "Content-Type: application/json" \
  -d '{"model":"YOUR_MODEL","messages":[{"role":"user","content":"Reply with {\"ok\":true}"}],
       "max_tokens":50,"response_format":{"type":"json_object"}}'

Env

FORGEBENCH_API_KEY and FORGEBENCH_BASE_URL, as in the connect recipe. Read them from the environment with no default value, add .env to .gitignore first, and name both in .env.example (no values).

Verify

Run the app's real call shape against mock-gpt. A 200 with a trace_id means the request was accepted. A 422 names the field or role the gateway rejected. A 200 does not prove a dropped field was applied: check the list above, not the response.

curl -s -w "\n%{http_code}\n" -X POST "$FORGEBENCH_BASE_URL/v1/chat/completions" \
  -H "Authorization: Bearer $FORGEBENCH_API_KEY" -H "Content-Type: application/json" \
  -d '{"model":"mock-gpt","messages":[{"role":"user","content":"ping"}],"max_tokens":20}'

Then run the app so that it makes one call, and call forgebench_integrate verify with the model it uses. It checks the newest call, so run the app just before and pass minutes: 2: an older call then cannot stand in for it. If you cannot run the app, say so in your summary.

What you get

Accepted calls pass through budget, audit, and trace handling. Forgebench forwards declared inference fields after policy checks and credential sanitization.

Pitfalls

  • Unknown top-level fields give no warning. Check the supported inventory before relying on a provider-specific option.
  • response_format is forwarded, not enforced by Forgebench. Whether the model honors a json_schema depends on the model, so parse defensively. A deny-mode output guardrail in the workspace is a separate check, and it blocks streaming.
  • strict: true is forwarded. The provider must support it, and your application must still validate tool arguments before use.
  • The user field sets the end-user identity in traces. It is not forwarded to the provider. See the metadata recipe.
  • Do not add provider-specific fields to the body, for example a provider API key or base URL: they are stripped.

Cookie settings

Our Cookie Policy lists every cookie and what it does.