mirror of
https://github.com/wassname/openrouter-python-sdk-retry-errors.git
synced 2026-07-31 12:30:30 +08:00
- 50539a3577b5a7e925b756f6bb87744052701215 - 2cdbe64441ce4435ea0a1ff9127472e815fdaccf - f35bb49a8b788937fa61c0cf4591b14f2bc8b217 - 08a37babde9ad8df5e24e0cd865d3292b1627464 - 7ddc8e1ed230ca489bc11a5e14696c209ea76349 - ad31290f38f3f02627f3e1953f1d7cf3e06159a5 - fb7f764b500618e322f56d49997fbcfaebba7e39 - 4306c032b9b4f3cfefeacdd3d243b0336f3b2f15 GitOrigin-RevId: 50539a3577b5a7e925b756f6bb87744052701215
38 KiB
38 KiB
ChatGenerationParams
Chat completion request parameters
Fields
| Field | Type | Required | Description | Example |
|---|---|---|---|---|
provider |
OptionalNullable[components.ChatGenerationParamsProvider] | ➖ | When multiple model providers are available, optionally indicate your routing preference. | |
plugins |
List[components.ChatGenerationParamsPluginUnion] | ➖ | Plugins you want to enable for this request, including their settings. | |
user |
Optional[str] | ➖ | Unique user identifier | user-123 |
session_id |
Optional[str] | ➖ | A unique identifier for grouping related requests (e.g., a conversation or agent workflow) for observability. If provided in both the request body and the x-session-id header, the body value takes precedence. Maximum of 128 characters. | |
trace |
Optional[components.ChatGenerationParamsTrace] | ➖ | Metadata for observability and tracing. Known keys (trace_id, trace_name, span_name, generation_name, parent_span_id) have special handling. Additional keys are passed through as custom metadata to configured broadcast destinations. | |
messages |
List[components.Message] | ✔️ | List of messages for the conversation | [ { "role": "user", "content": "Hello!" } ] |
model |
Optional[str] | ➖ | Model to use for completion | openai/gpt-4 |
models |
List[str] | ➖ | Models to use for completion | [ "openai/gpt-4", "openai/gpt-4o" ] |
frequency_penalty |
OptionalNullable[float] | ➖ | Frequency penalty (-2.0 to 2.0) | 0 |
logit_bias |
Dict[str, float] | ➖ | Token logit bias adjustments | { "50256": -100 } |
logprobs |
OptionalNullable[bool] | ➖ | Return log probabilities | false |
top_logprobs |
OptionalNullable[float] | ➖ | Number of top log probabilities to return (0-20) | 5 |
max_completion_tokens |
OptionalNullable[float] | ➖ | Maximum tokens in completion | 100 |
max_tokens |
OptionalNullable[float] | ➖ | Maximum tokens (deprecated, use max_completion_tokens). Note: some providers enforce a minimum of 16. | 100 |
metadata |
Dict[str, str] | ➖ | Key-value pairs for additional object information (max 16 pairs, 64 char keys, 512 char values) | { "user_id": "user-123", "session_id": "session-456" } |
presence_penalty |
OptionalNullable[float] | ➖ | Presence penalty (-2.0 to 2.0) | 0 |
reasoning |
Optional[components.Reasoning] | ➖ | Configuration options for reasoning models | { "effort": "medium", "summary": "concise" } |
response_format |
Optional[components.ResponseFormat] | ➖ | Response format configuration | { "type": "json_object" } |
seed |
OptionalNullable[int] | ➖ | Random seed for deterministic outputs | 42 |
stop |
OptionalNullable[components.Stop] | ➖ | Stop sequences (up to 4) | [ "" ] |
stream |
Optional[bool] | ➖ | Enable streaming response | false |
stream_options |
OptionalNullable[components.ChatStreamOptions] | ➖ | Streaming configuration options | { "include_usage": true } |
temperature |
OptionalNullable[float] | ➖ | Sampling temperature (0-2) | 0.7 |
parallel_tool_calls |
OptionalNullable[bool] | ➖ | N/A | |
tool_choice |
Optional[components.ToolChoiceOption] | ➖ | Tool choice configuration | auto |
tools |
List[components.ToolDefinitionJSON] | ➖ | Available tools for function calling | [ { "type": "function", "function": { "name": "get_weather", "description": "Get weather" } } ] |
top_p |
OptionalNullable[float] | ➖ | Nucleus sampling parameter (0-1) | 1 |
debug |
Optional[components.DebugOptions] | ➖ | Debug options for inspecting request transformations (streaming only) | { "echo_upstream_body": true } |
image_config |
Dict[str, components.ChatGenerationParamsImageConfig] | ➖ | Provider-specific image configuration options. Keys and values vary by model/provider. See https://openrouter.ai/docs/guides/overview/multimodal/image-generation for more details. | { "aspect_ratio": "16:9" } |
modalities |
List[components.Modality] | ➖ | Output modalities for the response. Supported values are "text", "image", and "audio". | [ "text", "image" ] |
cache_control |
Optional[components.CacheControl] | ➖ | Enable automatic prompt caching. When set, the system automatically applies cache breakpoints to the last cacheable block in the request. Currently supported for Anthropic Claude models. |