chat
Send chat completion requests to any OpenRouter model. Configure model, system prompt, and sampling parameters like temperature and max tokens.
Instructions
Send a chat completion request to any OpenRouter model.
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| seed | No | Random seed for deterministic outputs | |
| stop | No | List of stop sequences | |
| model | No | Model identifier (e.g., "anthropic/claude-sonnet-4", "openai/gpt-4o"). If not specified, uses DEFAULT_TEXT_MODEL environment variable. | |
| top_k | No | Top-k sampling (number of top tokens to consider) | |
| top_p | No | Nucleus sampling threshold 0-1 | |
| prompt | No | User message to send (provide either prompt or messages, not both) | |
| system | No | Optional system prompt to set context | |
| messages | No | Multi-turn conversation as a list of {role, content} dicts (provide either prompt or messages, not both) | |
| provider | No | Provider routing control (e.g., {"order": ["Anthropic", "Google"]}) | |
| json_mode | No | If True, request JSON-formatted response (backward compat) | |
| max_tokens | No | Maximum tokens in response (model default if not specified) | |
| temperature | No | Sampling temperature 0-2 (model default if not specified) | |
| response_format | No | Response format spec, e.g. {"type": "json_schema", ...}. Supersedes json_mode if both provided. | |
| presence_penalty | No | Penalize tokens already present (-2 to 2) | |
| reasoning_effort | No | Reasoning effort level: "minimal", "medium", or "high" | |
| assistant_prefill | No | Text to prefill the assistant response with | |
| frequency_penalty | No | Penalize repeated tokens (-2 to 2) |
Output Schema
| Name | Required | Description | Default |
|---|---|---|---|
| result | Yes |