For AI agents: a documentation index is available at the root level at /llms.txt and /llms-full.txt. Append /llms.txt to any URL for a page-level index, or .md for the markdown version of any page.
ModelsChatRankingsDocs
DocsAPI ReferenceClient SDKsAgent SDKCookbookChangelog
DocsAPI ReferenceClient SDKsAgent SDKCookbookChangelog
  • API Guides
    • Overview
    • Streaming
    • Embeddings
    • Limits
    • Authentication
    • Parameters
    • Errors and Debugging
  • API Reference
      • POSTCreate a preset from a chat-completions request body
      • POSTCreate a preset from a messages request body
      • POSTCreate a preset from a responses request body
LogoLogo
ModelsChatRankingsDocs
API ReferencePresets

Create a preset from a messages request body

POST
https://openrouter.ai/api/v1/presets/:slug/messages
POST
/api/v1/presets/:slug/messages
$curl -X POST https://openrouter.ai/api/v1/presets/my-preset/messages \
> -H "Authorization: Bearer <token>" \
> -H "Content-Type: application/json" \
> -d '{
> "messages": [
> {
> "content": "Hello!",
> "role": "user"
> }
> ],
> "model": "anthropic/claude-4.6-sonnet",
> "max_tokens": 1024,
> "system": "You are a helpful assistant."
>}'
1{
2 "data": {
3 "created_at": "2026-04-20T10:00:00Z",
4 "creator_user_id": "user_2dHFtVWx2n56w6HkM0000000000",
5 "description": null,
6 "designated_version": {
7 "config": {
8 "max_tokens": 1024,
9 "model": "anthropic/claude-4.6-sonnet"
10 },
11 "created_at": "2026-04-20T10:00:00Z",
12 "creator_id": "user_2dHFtVWx2n56w6HkM0000000000",
13 "id": "550e8400-e29b-41d4-a716-446655440000",
14 "preset_id": "650e8400-e29b-41d4-a716-446655440001",
15 "system_prompt": "You are a helpful assistant.",
16 "updated_at": "2026-04-20T10:00:00Z",
17 "version": 1
18 },
19 "designated_version_id": "550e8400-e29b-41d4-a716-446655440000",
20 "id": "650e8400-e29b-41d4-a716-446655440001",
21 "name": "my-preset",
22 "slug": "my-preset",
23 "status": "active",
24 "status_updated_at": null,
25 "updated_at": "2026-04-20T10:00:00Z",
26 "workspace_id": "750e8400-e29b-41d4-a716-446655440002"
27 }
28}

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.

Was this page helpful?
Previous

Create a preset from a responses request body

Next
Built with

Authentication

AuthorizationBearer
API key as bearer token in Authorization header

Path parameters

slugstringRequired>=1 character

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

Request

This endpoint expects an object.
messageslist of objects or nullRequired
modelstringRequired
cache_controlobjectOptional
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.
context_managementobject or nullOptional
max_tokensintegerOptional
metadataobjectOptional
modelslist of stringsOptional
output_configobjectOptional
Configuration for controlling output behavior. Supports the effort parameter and structured output format.
pluginslist of objectsOptional
Plugins you want to enable for this request, including their settings.
providerobjectOptional
When multiple model providers are available, optionally indicate your routing preference.
routeanyOptional
service_tierstringOptional
session_idstringOptional<=256 characters

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.

speedenumOptional
Allowed values:
stop_sequenceslist of stringsOptional
stop_server_tools_whenlist of objectsOptional

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

streambooleanOptional
systemstring or list of objectsOptional
temperaturedoubleOptional
thinkingobjectOptional
tool_choiceobjectOptional
toolslist of objectsOptional
top_kintegerOptional
top_pdoubleOptional
traceobjectOptional

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.

userstringOptional<=256 characters

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.

Response

Preset created or updated successfully.
dataobject
A preset with its currently designated version.

Errors

400
Bad Request Error
401
Unauthorized Error
403
Forbidden Error
404
Not Found Error
409
Conflict Error
500
Internal Server Error