Создание пресета из тела запроса messages
Создаёт пресет (или новую версию существующего пресета) на основе тела запроса на выполнение. Сохраняются только поля, соответствующие конфигурации пресета; остальные поля (например,
messages,stream,prompt) молча игнорируются.
OpenAPI
yaml
openapi: 3.1.0
info:
contact:
email: support@openrouter.ai
name: OpenRouter Support
url: https://openrouter.ai/docs
description: OpenAI-compatible API with additional OpenRouter features
license:
name: MIT
url: https://opensource.org/licenses/MIT
title: OpenRouter API
version: 1.0.0
servers:
- description: Production server
url: https://openrouter.ai/api/v1
x-speakeasy-server-id: production
security:
- apiKey: []
tags:
- description: API key management endpoints
name: API Keys
- description: Analytics and usage endpoints
name: Analytics
- description: Anthropic Messages endpoints
name: Anthropic Messages
- description: BYOK endpoints
name: BYOK
- description: Benchmarks endpoints
name: Benchmarks
- description: Chat completion endpoints
name: Chat
- description: Task classification market-share endpoints
name: Classifications
- description: Credit management endpoints
name: Credits
- description: >-
Public OpenRouter usage datasets. Data returned by these endpoints is
licensed under CC BY 4.0 (https://creativecommons.org/licenses/by/4.0/):
reuse and republish it, including commercially, with attribution to
OpenRouter.
name: Datasets
- description: Text embedding endpoints
name: Embeddings
- description: Endpoint information
name: Endpoints
- description: Files endpoints
name: Files
- description: Generation history endpoints
name: Generations
- description: Guardrails endpoints
name: Guardrails
- description: Images endpoints
name: Images
- description: Model information endpoints
name: Models
- description: OAuth authentication endpoints
name: OAuth
- description: Observability endpoints
name: Observability
- description: Organization endpoints
name: Organization
- description: Presets endpoints
name: Presets
- description: Provider information endpoints
name: Providers
- description: Rerank endpoints
name: Rerank
- description: OpenAI-compatible Responses API endpoints
name: Responses
- description: SCIM endpoints
name: SCIM
- description: Speech-to-text endpoints
name: STT
x-displayName: Transcriptions
- description: Text-to-speech endpoints
name: TTS
x-displayName: Speech
- description: Video Generation endpoints
name: Video Generation
- description: Workspaces endpoints
name: Workspaces
- description: beta.Analytics endpoints
name: beta.Analytics
externalDocs:
description: OpenRouter Documentation
url: https://openrouter.ai/docs
paths:
/presets/{slug}/messages:
post:
tags:
- Presets
summary: Create a preset from a messages request body
description: >-
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.
operationId: createPresetsMessages
parameters:
- description: URL-safe slug identifying the preset. Created if it does not exist.
in: path
name: slug
required: true
schema:
description: >-
URL-safe slug identifying the preset. Created if it does not
exist.
example: my-preset
minLength: 1
type: string
requestBody:
content:
application/json:
example:
max_tokens: 1024
messages:
- content: Hello!
role: user
model: anthropic/claude-4.6-sonnet
system: You are a helpful assistant.
schema:
$ref: '#/components/schemas/MessagesRequest'
required: true
responses:
'200':
content:
application/json:
example:
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
schema:
$ref: '#/components/schemas/CreatePresetFromInferenceResponse'
description: Preset created or updated successfully.
'400':
content:
application/json:
example:
error:
code: 400
message: Invalid request parameters
schema:
$ref: '#/components/schemas/BadRequestResponse'
description: Bad Request - Invalid request parameters or malformed input
'401':
content:
application/json:
example:
error:
code: 401
message: Missing Authentication header
schema:
$ref: '#/components/schemas/UnauthorizedResponse'
description: Unauthorized - Authentication required or invalid credentials
'403':
content:
application/json:
example:
error:
code: 403
message: Only management keys can perform this operation
schema:
$ref: '#/components/schemas/ForbiddenResponse'
description: Forbidden - Authentication successful but insufficient permissions
'404':
content:
application/json:
example:
error:
code: 404
message: Resource not found
schema:
$ref: '#/components/schemas/NotFoundResponse'
description: Not Found - Resource does not exist
'409':
content:
application/json:
example:
error:
code: 409
message: Resource conflict. Please try again later.
schema:
$ref: '#/components/schemas/ConflictResponse'
description: Conflict - Resource conflict or concurrent modification
'500':
content:
application/json:
example:
error:
code: 500
message: Internal Server Error
schema:
$ref: '#/components/schemas/InternalServerResponse'
description: Internal Server Error - Unexpected server error
security:
- apiKey: []
components:
schemas:
MessagesRequest:
description: Request schema for Anthropic Messages API endpoint
example:
max_tokens: 1024
messages:
- content: Hello, how are you?
role: user
model: anthropic/claude-4.5-sonnet-20250929
temperature: 0.7
properties:
cache_control:
$ref: '#/components/schemas/AnthropicCacheControlDirective'
context_management:
properties:
edits:
items:
oneOf:
- properties:
clear_at_least:
$ref: '#/components/schemas/AnthropicInputTokensClearAtLeast'
clear_tool_inputs:
anyOf:
- type: boolean
- items:
type: string
type: array
- type: 'null'
exclude_tools:
items:
type: string
type:
- array
- 'null'
keep:
$ref: '#/components/schemas/AnthropicToolUsesKeep'
trigger:
discriminator:
mapping:
input_tokens:
$ref: '#/components/schemas/AnthropicInputTokensTrigger'
tool_uses:
$ref: '#/components/schemas/AnthropicToolUsesTrigger'
propertyName: type
oneOf:
- $ref: '#/components/schemas/AnthropicInputTokensTrigger'
- $ref: '#/components/schemas/AnthropicToolUsesTrigger'
type:
enum:
- clear_tool_uses_20250919
type: string
required:
- type
type: object
- properties:
keep:
anyOf:
- $ref: '#/components/schemas/AnthropicThinkingTurns'
- properties:
type:
enum:
- all
type: string
required:
- type
type: object
- enum:
- all
type: string
type:
enum:
- clear_thinking_20251015
type: string
required:
- type
type: object
- properties:
instructions:
type:
- string
- 'null'
pause_after_compaction:
type: boolean
trigger:
anyOf:
- allOf:
- $ref: >-
#/components/schemas/AnthropicInputTokensTrigger
- properties: {}
type: object
- type: 'null'
example:
type: input_tokens
value: 100000
type:
enum:
- compact_20260112
type: string
required:
- type
type: object
type: array
type:
- object
- 'null'
fallbacks:
description: >-
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
items:
$ref: '#/components/schemas/MessagesFallbackParam'
type:
- array
- 'null'
max_tokens:
type: integer
messages:
items:
$ref: '#/components/schemas/MessagesMessageParam'
type:
- array
- 'null'
metadata:
properties:
user_id:
type:
- string
- 'null'
type: object
model:
type: string
models:
items:
type: string
type: array
output_config:
$ref: '#/components/schemas/MessagesOutputConfig'
plugins:
description: >-
Plugins you want to enable for this request, including their
settings.
items:
discriminator:
mapping:
auto-beta-router:
$ref: '#/components/schemas/AutoBetaRouterPlugin'
auto-router:
$ref: '#/components/schemas/AutoRouterPlugin'
context-compression:
$ref: '#/components/schemas/ContextCompressionPlugin'
file-parser:
$ref: '#/components/schemas/FileParserPlugin'
fusion:
$ref: '#/components/schemas/FusionPlugin'
moderation:
$ref: '#/components/schemas/ModerationPlugin'
pareto-router:
$ref: '#/components/schemas/ParetoRouterPlugin'
response-healing:
$ref: '#/components/schemas/ResponseHealingPlugin'
web:
$ref: '#/components/schemas/WebSearchPlugin'
web-fetch:
$ref: '#/components/schemas/WebFetchPlugin'
propertyName: id
oneOf:
- $ref: '#/components/schemas/AutoRouterPlugin'
- $ref: '#/components/schemas/AutoBetaRouterPlugin'
- $ref: '#/components/schemas/ModerationPlugin'
- $ref: '#/components/schemas/WebSearchPlugin'
- $ref: '#/components/schemas/WebFetchPlugin'
- $ref: '#/components/schemas/FileParserPlugin'
- $ref: '#/components/schemas/ResponseHealingPlugin'
- $ref: '#/components/schemas/ContextCompressionPlugin'
- $ref: '#/components/schemas/ParetoRouterPlugin'
- $ref: '#/components/schemas/FusionPlugin'
type: array
provider:
$ref: '#/components/schemas/ProviderPreferences'
route:
$ref: '#/components/schemas/DeprecatedRoute'
service_tier:
type: string
session_id:
description: >-
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.
maxLength: 256
type: string
speed:
allOf:
- $ref: '#/components/schemas/AnthropicSpeed'
- description: >-
Controls output generation speed. When set to `fast`, uses a
higher-speed inference configuration at premium pricing.
Defaults to `standard` when omitted.
example: fast
stop_sequences:
items:
type: string
type: array
stop_server_tools_when:
$ref: '#/components/schemas/StopServerToolsWhen'
stream:
type: boolean
system:
anyOf:
- type: string
- items:
$ref: '#/components/schemas/AnthropicTextBlockParam'
type: array
temperature:
format: double
type: number
thinking:
oneOf:
- properties:
budget_tokens:
type: integer
display:
$ref: '#/components/schemas/AnthropicThinkingDisplay'
type:
enum:
- enabled
type: string
required:
- type
- budget_tokens
type: object
- properties:
type:
enum:
- disabled
type: string
required:
- type
type: object
- properties:
display:
$ref: '#/components/schemas/AnthropicThinkingDisplay'
type:
enum:
- adaptive
type: string
required:
- type
type: object
tool_choice:
oneOf:
- properties:
disable_parallel_tool_use:
type: boolean
type:
enum:
- auto
type: string
required:
- type
type: object
- properties:
disable_parallel_tool_use:
type: boolean
type:
enum:
- any
type: string
required:
- type
type: object
- properties:
type:
enum:
- none
type: string
required:
- type
type: object
- properties:
disable_parallel_tool_use:
type: boolean
name:
type: string
type:
enum:
- tool
type: string
required:
- type
- name
type: object
tools:
items:
anyOf:
- properties:
cache_control:
$ref: '#/components/schemas/AnthropicCacheControlDirective'
defer_loading:
type: boolean
description:
type: string
input_schema:
additionalProperties: {}
properties:
properties: {}
required:
items:
type: string
type:
- array
- 'null'
type:
default: object
type: string
type: object
name:
type: string
type:
enum:
- custom
type: string
required:
- name
- input_schema
type: object
- properties:
cache_control:
$ref: '#/components/schemas/AnthropicCacheControlDirective'
name:
enum:
- bash
type: string
type:
enum:
- bash_20250124
type: string
required:
- type
- name
type: object
- properties:
cache_control:
$ref: '#/components/schemas/AnthropicCacheControlDirective'
name:
enum:
- str_replace_editor
type: string
type:
enum:
- text_editor_20250124
type: string
required:
- type
- name
type: object
- properties:
allowed_domains:
items:
type: string
type:
- array
- 'null'
blocked_domains:
items:
type: string
type:
- array
- 'null'
cache_control:
$ref: '#/components/schemas/AnthropicCacheControlDirective'
max_uses:
type:
- integer
- 'null'
name:
enum:
- web_search
type: string
type:
enum:
- web_search_20250305
type: string
user_location:
$ref: '#/components/schemas/AnthropicWebSearchToolUserLocation'
required:
- type
- name
type: object
- properties:
allowed_callers:
$ref: '#/components/schemas/AnthropicAllowedCallers'
allowed_domains:
items:
type: string
type:
- array
- 'null'
blocked_domains:
items:
type: string
type:
- array
- 'null'
cache_control:
$ref: '#/components/schemas/AnthropicCacheControlDirective'
max_uses:
type:
- integer
- 'null'
name:
enum:
- web_search
type: string
type:
enum:
- web_search_20260209
type: string
user_location:
$ref: '#/components/schemas/AnthropicWebSearchToolUserLocation'
required:
- type
- name
type: object
- properties:
allowed_callers:
$ref: '#/components/schemas/AnthropicAllowedCallers'
cache_control:
$ref: '#/components/schemas/AnthropicCacheControlDirective'
caching:
anyOf:
- $ref: '#/components/schemas/AnthropicCacheControlDirective'
- type: 'null'
defer_loading:
type: boolean
max_uses:
type: integer
model:
type: string
name:
enum:
- advisor
type: string
type:
enum:
- advisor_20260301
type: string
required:
- type
- name
- model
type: object
- $ref: '#/components/schemas/BashServerTool'
- $ref: '#/components/schemas/DatetimeServerTool'
- $ref: '#/components/schemas/ImageGenerationServerTool_OpenRouter'
- $ref: '#/components/schemas/MessagesSearchModelsServerTool'
- $ref: '#/components/schemas/WebFetchServerTool'
- $ref: '#/components/schemas/OpenRouterWebSearchServerTool'
- additionalProperties: {}
properties:
type:
type: string
required:
- type
type: object
- $ref: '#/components/schemas/AnthropicToolSearchToolBm25'
- $ref: '#/components/schemas/AnthropicToolSearchToolRegex'
- $ref: '#/components/schemas/ShellServerTool_OpenRouter'
type: array
top_k:
type: integer
top_p:
format: double
type: number
trace:
$ref: '#/components/schemas/TraceConfig'
user:
description: >-
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.
maxLength: 256
type: string
required:
- model
- messages
type: object
CreatePresetFromInferenceResponse:
description: Response containing the created preset with its designated version.
example:
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
properties:
data:
$ref: '#/components/schemas/PresetWithDesignatedVersion'
required:
- data
type: object
BadRequestResponse:
description: Bad Request - Invalid request parameters or malformed input
example:
error:
code: 400
message: Invalid request parameters
properties:
error:
$ref: '#/components/schemas/BadRequestResponseErrorData'
openrouter_metadata:
additionalProperties: {}
type:
- object
- 'null'
user_id:
type:
- string
- 'null'
required:
- error
type: object
UnauthorizedResponse:
description: Unauthorized - Authentication required or invalid credentials
example:
error:
code: 401
message: Missing Authentication header
properties:
error:
$ref: '#/components/schemas/UnauthorizedResponseErrorData'
openrouter_metadata:
additionalProperties: {}
type:
- object
- 'null'
user_id:
type:
- string
- 'null'
required:
- error
type: object
ForbiddenResponse:
description: Forbidden - Authentication successful but insufficient permissions
example:
error:
code: 403
message: Only management keys can perform this operation
properties:
error:
$ref: '#/components/schemas/ForbiddenResponseErrorData'
openrouter_metadata:
additionalProperties: {}
type:
- object
- 'null'
user_id:
type:
- string
- 'null'
required:
- error
type: object
NotFoundResponse:
description: Not Found - Resource does not exist
example:
error:
code: 404
message: Resource not found
properties:
error:
$ref: '#/components/schemas/NotFoundResponseErrorData'
openrouter_metadata:
additionalProperties: {}
type:
- object
- 'null'
user_id:
type:
- string
- 'null'
required:
- error
type: object
ConflictResponse:
description: Conflict - Resource conflict or concurrent modification
example:
error:
code: 409
message: Resource conflict. Please try again later.
properties:
error:
$ref: '#/components/schemas/ConflictResponseErrorData'
openrouter_metadata:
additionalProperties: {}
type:
- object
- 'null'
user_id:
type:
- string
- 'null'
required:
- error
type: object
InternalServerResponse:
description: Internal Server Error - Unexpected server error
example:
error:
code: 500
message: Internal Server Error
properties:
error:
$ref: '#/components/schemas/InternalServerResponseErrorData'
openrouter_metadata:
additionalProperties: {}
type:
- object
- 'null'
user_id:
type:
- string
- 'null'
required:
- error
type: object
AnthropicCacheControlDirective:
description: >-
Enable automatic prompt caching. When set at the top level, the system
automatically applies cache breakpoints to the last cacheable block in
the request. When set on an individual content block, it marks an
explicit cache breakpoint; block-level markers also work on OpenAI
models that support explicit prompt caching — OpenRouter converts them
to the provider's native format.
example:
type: ephemeral
properties:
ttl:
$ref: '#/components/schemas/AnthropicCacheControlTtl'
type:
enum:
- ephemeral
type: string
required:
- type
type: object
AnthropicInputTokensClearAtLeast:
example:
type: input_tokens
value: 50000
properties:
type:
enum:
- input_tokens
type: string
value:
type: integer
required:
- type
- value
type:
- object
- 'null'
AnthropicToolUsesKeep:
example:
type: tool_uses
value: 5
properties:
type:
enum:
- tool_uses
type: string
value:
type: integer
required:
- type
- value
type: object
AnthropicInputTokensTrigger:
example:
type: input_tokens
value: 100000
properties:
type:
enum:
- input_tokens
type: string
value:
type: integer
required:
- type
- value
type: object
AnthropicToolUsesTrigger:
example:
type: tool_uses
value: 10
properties:
type:
enum:
- tool_uses
type: string
value:
type: integer
required:
- type
- value
type: object
AnthropicThinkingTurns:
example:
type: thinking_turns
value: 3
properties:
type:
enum:
- thinking_turns
type: string
value:
type: integer
required:
- type
- value
type: object
MessagesFallbackParam:
additionalProperties: {}
description: >-
Fallback model to try when the primary model fails or refuses. Only the
`model` field is supported; per-attempt overrides are rejected.
example:
model: claude-opus-4-8
properties:
model:
type: string
required:
- model
type: object
MessagesMessageParam:
description: Anthropic message with OpenRouter extensions
example:
content: Hello, how are you?
role: user
properties:
content:
anyOf:
- type: string
- items:
oneOf:
- $ref: '#/components/schemas/AnthropicTextBlockParam'
- $ref: '#/components/schemas/AnthropicImageBlockParam'
- $ref: '#/components/schemas/AnthropicDocumentBlockParam'
- properties:
cache_control:
$ref: '#/components/schemas/AnthropicCacheControlDirective'
id:
type: string
input: {}
name:
type: string
type:
enum:
- tool_use
type: string
required:
- type
- id
- name
type: object
- properties:
cache_control:
$ref: '#/components/schemas/AnthropicCacheControlDirective'
content:
anyOf:
- type: string
- items:
anyOf:
- $ref: '#/components/schemas/AnthropicTextBlockParam'
- $ref: >-
#/components/schemas/AnthropicImageBlockParam
- properties:
tool_name:
type: string
type:
enum:
- tool_reference
type: string
required:
- type
- tool_name
type: object
- $ref: >-
#/components/schemas/AnthropicSearchResultBlockParam
- $ref: >-
#/components/schemas/AnthropicDocumentBlockParam
type: array
is_error:
type: boolean
tool_use_id:
type: string
type:
enum:
- tool_result
type: string
required:
- type
- tool_use_id
type: object
- properties:
signature:
type: string
thinking:
type: string
type:
enum:
- thinking
type: string
required:
- type
- thinking
- signature
type: object
- properties:
data:
type: string
type:
enum:
- redacted_thinking
type: string
required:
- type
- data
type: object
- properties:
cache_control:
$ref: '#/components/schemas/AnthropicCacheControlDirective'
id:
type: string
input: {}
name:
type: string
type:
enum:
- server_tool_use
type: string
required:
- type
- id
- name
type: object
- properties:
cache_control:
$ref: '#/components/schemas/AnthropicCacheControlDirective'
content:
anyOf:
- items:
$ref: >-
#/components/schemas/AnthropicWebSearchResultBlockParam
type: array
- properties:
error_code:
enum:
- invalid_tool_input
- unavailable
- max_uses_exceeded
- too_many_requests
- query_too_long
type: string
type:
enum:
- web_search_tool_result_error
type: string
required:
- type
- error_code
type: object
tool_use_id:
type: string
type:
enum:
- web_search_tool_result
type: string
required:
- type
- tool_use_id
- content
type: object
- $ref: '#/components/schemas/AnthropicSearchResultBlockParam'
- properties:
cache_control:
$ref: '#/components/schemas/AnthropicCacheControlDirective'
content:
type:
- string
- 'null'
encrypted_content:
type:
- string
- 'null'
type:
enum:
- compaction
type: string
required:
- type
- content
type: object
- $ref: '#/components/schemas/MessagesAdvisorToolResultBlock'
- $ref: '#/components/schemas/MessagesToolAdditionBlock'
- $ref: '#/components/schemas/MessagesToolRemovalBlock'
- $ref: '#/components/schemas/MessagesShellToolResultBlock'
- $ref: '#/components/schemas/MessagesBashToolResultBlock'
type: array
role:
enum:
- user
- assistant
- system
type: string
required:
- role
- content
type: object