Skip to main content
POST
/
presets
/
{slug}
/
messages
Create a preset from a messages request body
curl --request POST \
  --url https://openrouter.ai/api/v1/presets/{slug}/messages \
  --header 'Authorization: Bearer <token>' \
  --header 'Content-Type: application/json' \
  --data '
{
  "max_tokens": 1024,
  "messages": [
    {
      "content": "Hello!",
      "role": "user"
    }
  ],
  "model": "anthropic/claude-4.6-sonnet",
  "system": "You are a helpful assistant."
}
'
{
  "data": {
    "created_at": "2026-04-20T10:00:00Z",
    "creator_user_id": "user_2dHFtVWx2n56w6HkM0000000000",
    "description": null,
    "designated_version": {
      "config": {
        "max_tokens": 1024,
        "model": "anthropic/claude-4.6-sonnet"
      },
      "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"
  }
}

Authorizations

Authorization
string
header
required

API key as bearer token in Authorization header

Path Parameters

slug
string
required

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

Minimum string length: 1
Example:

"my-preset"

Body

application/json

Request schema for Anthropic Messages API endpoint

messages
object[] | null
required
model
string
required
cache_control
object

Enable automatic prompt caching. When set at the top level, the system automatically applies cache breakpoints to the last cacheable block in the request. Currently supported for Anthropic Claude models.

Example:
{ "type": "ephemeral" }
context_management
object | null
fallbacks
object[] | null

Fallback models to try if the primary model fails or refuses, in order. Handled by OpenRouter multi-model routing rather than Anthropic server-side fallbacks; cannot be combined with models. Each entry accepts only model. Maximum of 3 entries.

Example:
[{ "model": "claude-opus-4-8" }]
max_tokens
integer
metadata
object
models
string[]
output_config
object

Configuration for controlling output behavior. Supports the effort parameter and structured output format.

Example:
{ "effort": "medium" }
plugins
object[]

Plugins you want to enable for this request, including their settings.

Example:
{
"allowed_models": ["anthropic/*", "openai/gpt-4o"],
"cost_quality_tradeoff": 7,
"enabled": true,
"id": "auto-router"
}
provider
object | null

When multiple model providers are available, optionally indicate your routing preference.

Example:
{ "allow_fallbacks": true }
route
enum<string> | null
deprecated

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

Available options:
fallback,
sort,
null
Example:

"fallback"

service_tier
string
session_id
string

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.

Maximum string length: 256
speed
enum<string> | null

Controls output generation speed. When set to fast, uses a higher-speed inference configuration at premium pricing. Defaults to standard when omitted.

Available options:
fast,
standard,
null
Example:

"fast"

stop_sequences
string[]
stop_server_tools_when
object[]

Stop conditions for the server-tool agent loop. Any condition firing halts the loop (OR logic). When set, this overrides max_tool_calls.

Minimum array length: 1

A single condition that, when met, halts the server-tool agent loop.

Example:
{ "step_count": 5, "type": "step_count_is" }
Example:
[
{ "step_count": 5, "type": "step_count_is" },
{
"max_cost_in_dollars": 0.5,
"type": "max_cost"
}
]
stream
boolean
system
temperature
number<double>
thinking
object
tool_choice
object
tools
object[]
top_k
integer
top_p
number<double>
trace
object

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.

Example:
{
"trace_id": "trace-abc123",
"trace_name": "my-app-trace"
}
user
string

A unique identifier representing your end-user, which helps distinguish between different users of your app. This allows your app to identify specific users in case of abuse reports, preventing your entire app from being affected by the actions of individual users. Maximum of 256 characters.

Maximum string length: 256

Response

Preset created or updated successfully.

Response containing the created preset with its designated version.

data
object
required

A preset with its currently designated version.

Example:
{
"created_at": "2026-04-20T10:00:00Z",
"creator_user_id": "user_2dHFtVWx2n56w6HkM0000000000",
"description": null,
"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",
"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
}
}