Создать пресет из тела запроса Responses

MD версия

Создаёт пресет (или новую версию существующего пресета) на основе тела запроса на выполнение. Сохраняются только поля, пересекающиеся с конфигурацией пресета; остальные поля (например, messages, stream, prompt) молча игнорируются.

OpenAPI

yaml
/openapi/openapi.yaml post /presets/{slug}/responses 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}/responses: post: tags: - Presets summary: Create a preset from a responses 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: createPresetsResponses 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: input: Hello! instructions: You are a helpful assistant. model: openai/gpt-5.4 schema: $ref: '#/components/schemas/ResponsesRequest' 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: model: openai/gpt-5.4 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: ResponsesRequest: description: Request schema for Responses endpoint example: input: - content: Hello, how are you? role: user type: message model: anthropic/claude-4.5-sonnet-20250929 temperature: 0.7 tools: - description: Get the current weather in a given location name: get_current_weather parameters: properties: location: type: string type: object type: function top_p: 0.9 properties: background: type: - boolean - 'null' cache_control: $ref: '#/components/schemas/AnthropicCacheControlDirective' debug: $ref: '#/components/schemas/ChatDebugOptions' frequency_penalty: format: double type: - number - 'null' image_config: $ref: '#/components/schemas/ImageConfig' include: items: $ref: '#/components/schemas/ResponseIncludesEnum' type: - array - 'null' input: $ref: '#/components/schemas/Inputs' instructions: type: - string - 'null' max_output_tokens: type: - integer - 'null' max_tool_calls: description: >- Maximum number of server-tool (e.g. `openrouter:web_search`) agent steps the model may take during a request. Defaults to 30, which is also the maximum. Ignored when `stop_server_tools_when` is set. example: 30 type: - integer - 'null' metadata: $ref: '#/components/schemas/RequestMetadata' modalities: description: >- Output modalities for the response. Supported values are "text" and "image". example: - text - image items: $ref: '#/components/schemas/OutputModalityEnum' type: array model: type: string models: items: type: string type: array parallel_tool_calls: type: - boolean - 'null' 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 presence_penalty: format: double type: - number - 'null' previous_response_id: description: >- Not supported. The Responses API is stateless: no responses are stored, so a previous response cannot be referenced. Requests with a non-null value are rejected with a 400 error. Send the full conversation history in `input` instead. prompt: $ref: '#/components/schemas/StoredPromptTemplate' prompt_cache_key: type: - string - 'null' prompt_cache_options: $ref: '#/components/schemas/PromptCacheOptions' provider: $ref: '#/components/schemas/ProviderPreferences' reasoning: $ref: '#/components/schemas/ReasoningConfig' route: $ref: '#/components/schemas/DeprecatedRoute' safety_identifier: description: >- Recommended 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: user-123 type: - string - 'null' service_tier: default: auto description: >- The service tier to use for processing this request. `fast` is accepted as an alias for `priority`. enum: - auto - default - fast - flex - priority - scale - null type: - string - 'null' 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 stop_server_tools_when: $ref: '#/components/schemas/StopServerToolsWhen' store: const: false default: false type: boolean stream: default: false type: boolean temperature: format: double type: - number - 'null' text: $ref: '#/components/schemas/TextExtendedConfig' tool_choice: $ref: '#/components/schemas/OpenAIResponsesToolChoice' tools: items: anyOf: - allOf: - $ref: '#/components/schemas/FunctionTool' - properties: {} type: object description: Function tool definition example: description: Get the current weather in a location name: get_weather parameters: properties: location: description: The city and state type: string unit: enum: - celsius - fahrenheit type: string required: - location type: object type: function - $ref: '#/components/schemas/Preview_WebSearchServerTool' - $ref: '#/components/schemas/Preview_20250311_WebSearchServerTool' - $ref: '#/components/schemas/Legacy_WebSearchServerTool' - $ref: '#/components/schemas/WebSearchServerTool' - $ref: '#/components/schemas/FileSearchServerTool' - $ref: '#/components/schemas/ComputerUseServerTool' - $ref: '#/components/schemas/CodeInterpreterServerTool' - $ref: '#/components/schemas/McpServerTool' - $ref: '#/components/schemas/ImageGenerationServerTool' - $ref: '#/components/schemas/CodexLocalShellTool' - $ref: '#/components/schemas/ShellServerTool' - $ref: '#/components/schemas/ApplyPatchServerTool' - $ref: '#/components/schemas/CustomTool' - $ref: '#/components/schemas/NamespaceTool' - $ref: '#/components/schemas/AdvisorServerTool_OpenRouter' - $ref: '#/components/schemas/SubagentServerTool_OpenRouter' - $ref: '#/components/schemas/DatetimeServerTool' - $ref: '#/components/schemas/FilesServerTool' - $ref: '#/components/schemas/FusionServerTool_OpenRouter' - $ref: '#/components/schemas/ImageGenerationServerTool_OpenRouter' - $ref: '#/components/schemas/SearchModelsServerTool_OpenRouter' - $ref: '#/components/schemas/WebFetchServerTool' - $ref: '#/components/schemas/WebSearchServerTool_OpenRouter' - $ref: '#/components/schemas/ApplyPatchServerTool_OpenRouter' - $ref: '#/components/schemas/BashServerTool' - $ref: '#/components/schemas/ShellServerTool_OpenRouter' type: array top_k: type: integer top_logprobs: type: - integer - 'null' top_p: format: double type: - number - 'null' trace: $ref: '#/components/schemas/TraceConfig' truncation: $ref: '#/components/schemas/OpenAIResponsesTruncation' 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 type: object