Presets

Create a preset from a chat-completions request body

Changed on

Creates a preset (or a new version of an existing one) from an inference request body. Only fields that overlap with the preset config are persisted; other fields (e.g. messages, stream, prompt) are silently ignored.

post/presets/{slug}/chat/completions

Request

  • Base URL: https://openrouter.ai/api/v1
  • URL: https://openrouter.ai/api/v1/presets/{slug}/chat/completions
  • Auth: HTTP bearer

Path parameters

slugstring required

URL-safe slug identifying the preset. Created if it does not exist.

Example:my-preset

Request body

frequency_penaltynumber double nullable

Frequency penalty (-2.0 to 2.0)

image_configImageConfig

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.

logit_biasobject nullable

Token logit bias adjustments

logprobsboolean nullable

Return log probabilities

max_completion_tokensinteger nullable

Maximum tokens in completion

max_tokensinteger nullable

Maximum tokens (deprecated, use max_completion_tokens). Note: some providers enforce a minimum of 16.

metadataobject

Key-value pairs for additional object information (max 16 pairs, 64 char keys, 512 char values)

min_pnumber double nullable

Minimum probability threshold relative to the most likely token. Tokens with probability below min_p * (probability of top token) are filtered out. Not all providers support this parameter.

modalitiesstring[]

Output modalities for the response. Supported values are "text", "image", and "audio".

modelstring

Model to use for completion

modelsstring[]

Models to use for completion

parallel_tool_callsboolean nullable

Whether to enable parallel function calling during tool use. When true, the model may generate multiple tool calls in a single response.

presence_penaltynumber double nullable

Presence penalty (-2.0 to 2.0)

prompt_cache_keystring nullable
reasoning_effort'max' | 'xhigh' | 'high' | 'medium' | 'low' | 'minimal' | 'none' | 'null' nullable

Shorthand for setting reasoning effort. Equivalent to setting reasoning.effort. Cannot be used simultaneously with reasoning.effort if they differ.

repetition_penaltynumber double nullable

Penalizes tokens based on how much they have already appeared in the text. A value of 1.0 means no penalty. Values above 1.0 penalize repeated tokens more strongly. Not all providers support this parameter.

route'fallback' | 'sort' | 'null' nullable

DEPRECATED Use providers.sort.partition instead. Backwards-compatible alias for providers.sort.partition. Accepts legacy values: "fallback" (maps to "model"), "sort" (maps to "none").

seedinteger nullable

Random seed for deterministic outputs

service_tier'auto' | 'default' | 'fast' | 'flex' | 'priority' | 'scale' | 'ultrafast' | 'null' nullable

The service tier to use for processing this request. fast is accepted as an alias for priority. ultrafast prefers ultrafast endpoints and falls back to priority, then default endpoints.

session_idstring

A unique identifier for grouping related requests (e.g., a conversation or agent workflow). When provided, OpenRouter uses it as the sticky routing key, routing all requests in the session to the same provider to maximize prompt cache hits. Also used for observability grouping. If provided in both the request body and the x-session-id header, the body value takes precedence. Maximum of 256 characters.

streamboolean

Enable streaming response

temperaturenumber double nullable

Sampling temperature (0-2)

top_anumber double nullable

Consider only tokens with "sufficiently high" probabilities based on the probability of the most likely token. Not all providers support this parameter.

top_kinteger nullable

Limits the model to choose from the top K most likely tokens at each step. A value of 1 means the model will always pick the most likely next token. Not all providers support this parameter.

top_logprobsinteger nullable

Number of top log probabilities to return (0-20)

top_pnumber double nullable

Nucleus sampling parameter (0-1)

userstring

Per-end-user identifier for abuse isolation. Use a stable ID, hash, or pseudonym. When a provider requires a user identity, OpenRouter folds it into the hashed identity sent upstream and never forwards it raw. If omitted, requests use an account-level identity, so provider policy blocks can affect the whole account.

Example request

{
  "max_tokens": 150,
  "messages": [
    {
      "content": "You are a helpful assistant.",
      "role": "system"
    },
    {
      "content": "What is the capital of France?",
      "role": "user"
    }
  ],
  "model": "openai/gpt-4",
  "temperature": 0.7
}

Response

Preset created or updated successfully.

Example response

{
  "data": {
    "created_at": "2026-04-20T10:00:00Z",
    "creator_user_id": "user_2dHFtVWx2n56w6HkM0000000000",
    "description": null,
    "designated_version": {
      "config": {
        "model": "openai/gpt-4o",
        "temperature": 0.7
      },
      "created_at": "2026-04-20T10:00:00Z",
      "creator_id": "user_2dHFtVWx2n56w6HkM0000000000",
      "id": "550e8400-e29b-41d4-a716-446655440000",
      "preset_id": "650e8400-e29b-41d4-a716-446655440001",
      "system_prompt": "You are a helpful assistant.",
      "updated_at": "2026-04-20T10:00:00Z",
      "version": 1
    },
    "designated_version_id": "550e8400-e29b-41d4-a716-446655440000",
    "id": "650e8400-e29b-41d4-a716-446655440001",
    "name": "my-preset",
    "slug": "my-preset",
    "status": "active",
    "status_updated_at": null,
    "updated_at": "2026-04-20T10:00:00Z",
    "workspace_id": "750e8400-e29b-41d4-a716-446655440002"
  }
}

Changes

    • info

      added armor discriminator mapping keys to the / request property

    • info

      added to the / request property oneOf list

    • breaking

      added the new required request property ////////

    • breaking

      added the new required request property ////////

    • breaking

      the /////// request property type changed from string to object

    • info

      the /////// request property's minLength was decreased from 1 to 0

    • info

      removed the pattern ^[^\n\r]*$ from the request property ///////