参数
采样与输出参数在各模型系列上如何生效。
OhMyGPT 不给采样和输出参数额外设默认值或限制,这些都由模型厂商决定。
在原生协议上
在模型的原生协议上,所有参数都按你发送的原样传给模型,包括各厂商特有的参数,例如 Mistral 的 safe_prompt、Qwen 的 enable_thinking。默认值和取值限制以厂商为准;如果厂商拒绝某个取值,你会收到它返回的错误信息。
通过 Chat Completions 调用 Claude 和 Gemini
通过 Chat Completions 调用 Claude 或 Gemini 时,下列参数会以厂商自己的字段名生效。标为 — 的,表示该模型没有对应项:
| Chat Completions | Claude | Gemini |
|---|---|---|
max_tokens、max_completion_tokens | max_tokens | maxOutputTokens |
temperature、top_p、top_k | temperature、top_p、top_k | temperature、topP、topK |
stop | stop_sequences | stopSequences |
frequency_penalty、presence_penalty | — | frequencyPenalty、presencePenalty |
seed | — | seed |
response_format,类型为 json_schema | output_config.format | responseMimeType 及 schema |
response_format,类型为 json_object | — | responseMimeType: "application/json" |
modalities 含 audio 或 image | — | responseModalities |
logprobs、top_logprobs、logit_bias、verbosity、audio、web_search_options、min_p、top_a、repetition_penalty | — | — |
n 大于 1 | 400 | 400 |
tools、tool_choice | tools、tool_choice | functionDeclarations、toolConfig |
parallel_tool_calls | disable_parallel_tool_use | — |
user | metadata.user_id | — |
reasoning_effort、thinking | 见思考 | 见思考 |
Claude 要求必须传 max_tokens;如果不传,OhMyGPT 会按该模型的最大输出长度发送。
模型没有对应项的参数不会发给它,请求照常执行,与 Anthropic 自己的 OpenAI SDK 兼容层对待 Claude 没有的字段一样。所以同一个请求体可以在不同模型之间通用,但这项设置按模型的默认行为生效,所以 Claude 不理会 seed。例外是 n:这些模型每个请求只返回一个结果,n 大于 1 会在请求到达模型之前返回 400 并指出 n,不产生费用。某项设置必须生效时,请发给有这项参数的模型。模型有的参数收不收某个取值(例如推理模型上的 temperature)由模型决定,它返回的错误会原样交给你。
要让 Claude 输出 JSON,请使用 json_schema 类型的 response_format:
curl https://api.ohmygpt.com/v1/chat/completions \
-H "Authorization: Bearer $OHMYGPT_API_KEY" \
-H "Content-Type: application/json" \
-d '{
"model": "anthropic/claude-haiku-4-5",
"max_tokens": 200,
"messages": [{"role": "user", "content": "Give me a color and its hex code."}],
"response_format": {
"type": "json_schema",
"json_schema": {
"name": "color",
"schema": {
"type": "object",
"properties": {"name": {"type": "string"}, "hex": {"type": "string"}},
"required": ["name", "hex"],
"additionalProperties": false
}
}
}
}'"message": { "role": "assistant", "content": "{\"hex\": \"#FF6B6B\", \"name\": \"Coral Red\"}" }路由
Chat Completions 和 Responses 中的 provider 用于选择由哪家供应商提供该模型。它由 OhMyGPT 读取,不会传给模型。详见供应商路由。