/**
* @stability unstable
* @since 1.0.0
*/
import * as Data from "effect/Data"
import * as Effect from "effect/Effect"
import * as Sse from "effect/encoding/Sse"
import * as HttpClient from "effect/http/HttpClient"
import * as HttpClientError from "effect/http/HttpClientError"
import * as HttpClientRequest from "effect/http/HttpClientRequest"
import * as HttpClientResponse from "effect/http/HttpClientResponse"
import type { SchemaError } from "effect/Schema"
import * as Schema from "effect/Schema"
import * as Stream from "effect/Stream"
// non-recursive definitions
export type AABenchmarkEntry = {
readonly "agentic_index": number | null
readonly "coding_index": number | null
readonly "intelligence_index": number | null
}
export const AABenchmarkEntry = Schema.Struct({
"agentic_index": Schema.Union([
Schema.Number.check(Schema.isFinite().annotate({ "expected": "a finite number" })),
Schema.Null
]).annotate({ "description": "Artificial Analysis Agentic Index score", "format": "double" }),
"coding_index": Schema.Union([
Schema.Number.check(Schema.isFinite().annotate({ "expected": "a finite number" })),
Schema.Null
]).annotate({ "description": "Artificial Analysis Coding Index score", "format": "double" }),
"intelligence_index": Schema.Union([
Schema.Number.check(Schema.isFinite().annotate({ "expected": "a finite number" })),
Schema.Null
]).annotate({ "description": "Artificial Analysis Intelligence Index score", "format": "double" })
}).annotate({ "description": "Artificial Analysis benchmark index scores.", "identifier": "AABenchmarkEntry" })
export type ActivityItem = {
readonly "byok_usage_inference": number
readonly "completion_tokens": number
readonly "date": string
readonly "endpoint_id": string
readonly "model": string
readonly "model_permaslug": string
readonly "prompt_tokens": number
readonly "provider_name": string
readonly "reasoning_tokens": number
readonly "requests": number
readonly "usage": number
}
export const ActivityItem = Schema.Struct({
"byok_usage_inference": Schema.Number.annotate({
"description": "BYOK inference cost in USD (external credits spent)",
"format": "double"
}).check(Schema.isFinite().annotate({ "expected": "a finite number" })),
"completion_tokens": Schema.Number.annotate({ "description": "Total completion tokens generated" }).check(
Schema.isInt().annotate({ "expected": "an integer" })
),
"date": Schema.String.annotate({ "description": "Date of the activity (YYYY-MM-DD format)" }),
"endpoint_id": Schema.String.annotate({ "description": "Unique identifier for the endpoint" }),
"model": Schema.String.annotate({ "description": "Model slug (e.g., \"openai/gpt-4.1\")" }),
"model_permaslug": Schema.String.annotate({ "description": "Model permaslug (e.g., \"openai/gpt-4.1-2025-04-14\")" }),
"prompt_tokens": Schema.Number.annotate({ "description": "Total prompt tokens used" }).check(
Schema.isInt().annotate({ "expected": "an integer" })
),
"provider_name": Schema.String.annotate({ "description": "Name of the provider serving this endpoint" }),
"reasoning_tokens": Schema.Number.annotate({ "description": "Total reasoning tokens used" }).check(
Schema.isInt().annotate({ "expected": "an integer" })
),
"requests": Schema.Number.annotate({ "description": "Number of requests made" }).check(
Schema.isInt().annotate({ "expected": "an integer" })
),
"usage": Schema.Number.annotate({ "description": "Total cost in USD (OpenRouter credits spent)", "format": "double" })
.check(Schema.isFinite().annotate({ "expected": "a finite number" }))
}).annotate({ "identifier": "ActivityItem" })
export type AdvisorNestedTool = { readonly "parameters"?: {}; readonly "type": string }
export const AdvisorNestedTool = Schema.Struct({
"parameters": Schema.optionalKey(Schema.Struct({})),
"type": Schema.String
}).annotate({
"description":
"A tool made available to the advisor sub-agent. Only OpenRouter server tools (e.g. openrouter:web_search) are supported; function tools are rejected because the advisor has no way to execute them. The advisor tool may not list itself.",
"identifier": "AdvisorNestedTool"
})
export type AdvisorReasoning = {
readonly "effort"?: "max" | "xhigh" | "high" | "medium" | "low" | "minimal" | "none"
readonly "max_tokens"?: number
}
export const AdvisorReasoning = Schema.Struct({
"effort": Schema.optionalKey(
Schema.Literals(["max", "xhigh", "high", "medium", "low", "minimal", "none"]).annotate({
"description": "Reasoning effort level for the advisor call."
})
),
"max_tokens": Schema.optionalKey(
Schema.Number.annotate({ "description": "Maximum number of reasoning tokens the advisor may use." }).check(
Schema.isInt().annotate({ "expected": "an integer" })
)
)
}).annotate({
"description":
"Reasoning configuration forwarded to the advisor call. Use this to control reasoning effort and token budget for models that support extended thinking.",
"identifier": "AdvisorReasoning"
})
export type AnthropicAdvisorToolResult = {
readonly "content": {}
readonly "tool_use_id": string
readonly "type": "advisor_tool_result"
}
export const AnthropicAdvisorToolResult = Schema.Struct({
"content": Schema.Struct({}),
"tool_use_id": Schema.String,
"type": Schema.Literal("advisor_tool_result")
}).annotate({ "identifier": "AnthropicAdvisorToolResult" })
export type AnthropicAllowedCallers = ReadonlyArray<"direct" | "code_execution_20250825" | "code_execution_20260120">
export const AnthropicAllowedCallers = Schema.Array(
Schema.Literals(["direct", "code_execution_20250825", "code_execution_20260120"])
).annotate({ "identifier": "AnthropicAllowedCallers" })
export type AnthropicBase64PdfSource = {
readonly "data": string
readonly "media_type": "application/pdf"
readonly "type": "base64"
}
export const AnthropicBase64PdfSource = Schema.Struct({
"data": Schema.String,
"media_type": Schema.Literal("application/pdf"),
"type": Schema.Literal("base64")
}).annotate({ "identifier": "AnthropicBase64PdfSource" })
export type AnthropicBashCodeExecutionOutput = {
readonly "file_id": string
readonly "type": "bash_code_execution_output"
}
export const AnthropicBashCodeExecutionOutput = Schema.Struct({
"file_id": Schema.String,
"type": Schema.Literal("bash_code_execution_output")
}).annotate({ "identifier": "AnthropicBashCodeExecutionOutput" })
export type AnthropicBashCodeExecutionToolResultError = {
readonly "error_code":
| "invalid_tool_input"
| "unavailable"
| "too_many_requests"
| "execution_time_exceeded"
| "output_file_too_large"
readonly "type": "bash_code_execution_tool_result_error"
}
export const AnthropicBashCodeExecutionToolResultError = Schema.Struct({
"error_code": Schema.Literals([
"invalid_tool_input",
"unavailable",
"too_many_requests",
"execution_time_exceeded",
"output_file_too_large"
]),
"type": Schema.Literal("bash_code_execution_tool_result_error")
}).annotate({ "identifier": "AnthropicBashCodeExecutionToolResultError" })
export type AnthropicCacheControlTtl = "5m" | "1h"
export const AnthropicCacheControlTtl = Schema.Literals(["5m", "1h"]).annotate({
"identifier": "AnthropicCacheControlTtl"
})
export type Objects_ = {
readonly "ephemeral_1h_input_tokens": number
readonly "ephemeral_5m_input_tokens": number
readonly [x: string]: Schema.Json
}
export const Objects_ = Schema.StructWithRest(
Schema.Struct({
"ephemeral_1h_input_tokens": Schema.Number.check(Schema.isInt().annotate({ "expected": "an integer" })),
"ephemeral_5m_input_tokens": Schema.Number.check(Schema.isInt().annotate({ "expected": "an integer" }))
}),
[Schema.Record(Schema.String, Schema.Json.annotate({ "expected": "JSON value" }))]
)
export type AnthropicCitationCharLocation = {
readonly "cited_text": string
readonly "document_index": number
readonly "document_title": string | null
readonly "end_char_index": number
readonly "file_id": string | null
readonly "start_char_index": number
readonly "type": "char_location"
}
export const AnthropicCitationCharLocation = Schema.Struct({
"cited_text": Schema.String,
"document_index": Schema.Number.check(Schema.isInt().annotate({ "expected": "an integer" })),
"document_title": Schema.Union([Schema.String, Schema.Null]),
"end_char_index": Schema.Number.check(Schema.isInt().annotate({ "expected": "an integer" })),
"file_id": Schema.Union([Schema.String, Schema.Null]),
"start_char_index": Schema.Number.check(Schema.isInt().annotate({ "expected": "an integer" })),
"type": Schema.Literal("char_location")
}).annotate({ "identifier": "AnthropicCitationCharLocation" })
export type AnthropicCitationCharLocationParam = {
readonly "cited_text": string
readonly "document_index": number
readonly "document_title": string | null
readonly "end_char_index": number
readonly "start_char_index": number
readonly "type": "char_location"
}
export const AnthropicCitationCharLocationParam = Schema.Struct({
"cited_text": Schema.String,
"document_index": Schema.Number.check(Schema.isInt().annotate({ "expected": "an integer" })),
"document_title": Schema.Union([Schema.String, Schema.Null]),
"end_char_index": Schema.Number.check(Schema.isInt().annotate({ "expected": "an integer" })),
"start_char_index": Schema.Number.check(Schema.isInt().annotate({ "expected": "an integer" })),
"type": Schema.Literal("char_location")
}).annotate({ "identifier": "AnthropicCitationCharLocationParam" })
export type AnthropicCitationContentBlockLocation = {
readonly "cited_text": string
readonly "document_index": number
readonly "document_title": string | null
readonly "end_block_index": number
readonly "file_id": string | null
readonly "start_block_index": number
readonly "type": "content_block_location"
}
export const AnthropicCitationContentBlockLocation = Schema.Struct({
"cited_text": Schema.String,
"document_index": Schema.Number.check(Schema.isInt().annotate({ "expected": "an integer" })),
"document_title": Schema.Union([Schema.String, Schema.Null]),
"end_block_index": Schema.Number.check(Schema.isInt().annotate({ "expected": "an integer" })),
"file_id": Schema.Union([Schema.String, Schema.Null]),
"start_block_index": Schema.Number.check(Schema.isInt().annotate({ "expected": "an integer" })),
"type": Schema.Literal("content_block_location")
}).annotate({ "identifier": "AnthropicCitationContentBlockLocation" })
export type AnthropicCitationContentBlockLocationParam = {
readonly "cited_text": string
readonly "document_index": number
readonly "document_title": string | null
readonly "end_block_index": number
readonly "start_block_index": number
readonly "type": "content_block_location"
}
export const AnthropicCitationContentBlockLocationParam = Schema.Struct({
"cited_text": Schema.String,
"document_index": Schema.Number.check(Schema.isInt().annotate({ "expected": "an integer" })),
"document_title": Schema.Union([Schema.String, Schema.Null]),
"end_block_index": Schema.Number.check(Schema.isInt().annotate({ "expected": "an integer" })),
"start_block_index": Schema.Number.check(Schema.isInt().annotate({ "expected": "an integer" })),
"type": Schema.Literal("content_block_location")
}).annotate({ "identifier": "AnthropicCitationContentBlockLocationParam" })
export type AnthropicCitationPageLocation = {
readonly "cited_text": string
readonly "document_index": number
readonly "document_title": string | null
readonly "end_page_number": number
readonly "file_id": string | null
readonly "start_page_number": number
readonly "type": "page_location"
}
export const AnthropicCitationPageLocation = Schema.Struct({
"cited_text": Schema.String,
"document_index": Schema.Number.check(Schema.isInt().annotate({ "expected": "an integer" })),
"document_title": Schema.Union([Schema.String, Schema.Null]),
"end_page_number": Schema.Number.check(Schema.isInt().annotate({ "expected": "an integer" })),
"file_id": Schema.Union([Schema.String, Schema.Null]),
"start_page_number": Schema.Number.check(Schema.isInt().annotate({ "expected": "an integer" })),
"type": Schema.Literal("page_location")
}).annotate({ "identifier": "AnthropicCitationPageLocation" })
export type AnthropicCitationPageLocationParam = {
readonly "cited_text": string
readonly "document_index": number
readonly "document_title": string | null
readonly "end_page_number": number
readonly "start_page_number": number
readonly "type": "page_location"
}
export const AnthropicCitationPageLocationParam = Schema.Struct({
"cited_text": Schema.String,
"document_index": Schema.Number.check(Schema.isInt().annotate({ "expected": "an integer" })),
"document_title": Schema.Union([Schema.String, Schema.Null]),
"end_page_number": Schema.Number.check(Schema.isInt().annotate({ "expected": "an integer" })),
"start_page_number": Schema.Number.check(Schema.isInt().annotate({ "expected": "an integer" })),
"type": Schema.Literal("page_location")
}).annotate({ "identifier": "AnthropicCitationPageLocationParam" })
export type Objects_1 = { readonly "enabled": boolean; readonly [x: string]: Schema.Json }
export const Objects_1 = Schema.StructWithRest(Schema.Struct({ "enabled": Schema.Boolean }), [
Schema.Record(Schema.String, Schema.Json.annotate({ "expected": "JSON value" }))
])
export type AnthropicCitationSearchResultLocation = {
readonly "cited_text": string
readonly "end_block_index": number
readonly "search_result_index": number
readonly "source": string
readonly "start_block_index": number
readonly "title": string | null
readonly "type": "search_result_location"
}
export const AnthropicCitationSearchResultLocation = Schema.Struct({
"cited_text": Schema.String,
"end_block_index": Schema.Number.check(Schema.isInt().annotate({ "expected": "an integer" })),
"search_result_index": Schema.Number.check(Schema.isInt().annotate({ "expected": "an integer" })),
"source": Schema.String,
"start_block_index": Schema.Number.check(Schema.isInt().annotate({ "expected": "an integer" })),
"title": Schema.Union([Schema.String, Schema.Null]),
"type": Schema.Literal("search_result_location")
}).annotate({ "identifier": "AnthropicCitationSearchResultLocation" })
export type AnthropicCitationSearchResultLocationParam = {
readonly "cited_text": string
readonly "end_block_index": number
readonly "search_result_index": number
readonly "source": string
readonly "start_block_index": number
readonly "title": string | null
readonly "type": "search_result_location"
}
export const AnthropicCitationSearchResultLocationParam = Schema.Struct({
"cited_text": Schema.String,
"end_block_index": Schema.Number.check(Schema.isInt().annotate({ "expected": "an integer" })),
"search_result_index": Schema.Number.check(Schema.isInt().annotate({ "expected": "an integer" })),
"source": Schema.String,
"start_block_index": Schema.Number.check(Schema.isInt().annotate({ "expected": "an integer" })),
"title": Schema.Union([Schema.String, Schema.Null]),
"type": Schema.Literal("search_result_location")
}).annotate({ "identifier": "AnthropicCitationSearchResultLocationParam" })
export type AnthropicCitationWebSearchResultLocation = {
readonly "cited_text": string
readonly "encrypted_index": string
readonly "title": string | null
readonly "type": "web_search_result_location"
readonly "url": string
}
export const AnthropicCitationWebSearchResultLocation = Schema.Struct({
"cited_text": Schema.String,
"encrypted_index": Schema.String,
"title": Schema.Union([Schema.String, Schema.Null]),
"type": Schema.Literal("web_search_result_location"),
"url": Schema.String
}).annotate({ "identifier": "AnthropicCitationWebSearchResultLocation" })
export type AnthropicCitationWebSearchResultLocationParam = {
readonly "cited_text": string
readonly "encrypted_index": string
readonly "title": string | null
readonly "type": "web_search_result_location"
readonly "url": string
}
export const AnthropicCitationWebSearchResultLocationParam = Schema.Struct({
"cited_text": Schema.String,
"encrypted_index": Schema.String,
"title": Schema.Union([Schema.String, Schema.Null]),
"type": Schema.Literal("web_search_result_location"),
"url": Schema.String
}).annotate({ "identifier": "AnthropicCitationWebSearchResultLocationParam" })
export type AnthropicCodeExecution20250825Caller = {
readonly "tool_id": string
readonly "type": "code_execution_20250825"
}
export const AnthropicCodeExecution20250825Caller = Schema.Struct({
"tool_id": Schema.String,
"type": Schema.Literal("code_execution_20250825")
}).annotate({ "identifier": "AnthropicCodeExecution20250825Caller" })
export type AnthropicCodeExecution20260120Caller = {
readonly "tool_id": string
readonly "type": "code_execution_20260120"
}
export const AnthropicCodeExecution20260120Caller = Schema.Struct({
"tool_id": Schema.String,
"type": Schema.Literal("code_execution_20260120")
}).annotate({ "identifier": "AnthropicCodeExecution20260120Caller" })
export type AnthropicCodeExecutionOutput = { readonly "file_id": string; readonly "type": "code_execution_output" }
export const AnthropicCodeExecutionOutput = Schema.Struct({
"file_id": Schema.String,
"type": Schema.Literal("code_execution_output")
}).annotate({ "identifier": "AnthropicCodeExecutionOutput" })
export type AnthropicCompactionBlock = { readonly "content": string | null; readonly "type": "compaction" }
export const AnthropicCompactionBlock = Schema.Struct({
"content": Schema.Union([Schema.String, Schema.Null]),
"type": Schema.Literal("compaction")
}).annotate({ "identifier": "AnthropicCompactionBlock" })
export type AnthropicContainer = {
readonly "expires_at": string
readonly "id": string
readonly [x: string]: Schema.Json
} | null
export const AnthropicContainer = Schema.Union([
Schema.StructWithRest(Schema.Struct({ "expires_at": Schema.String, "id": Schema.String }), [
Schema.Record(Schema.String, Schema.Json.annotate({ "expected": "JSON value" }))
]),
Schema.Null
]).annotate({ "identifier": "AnthropicContainer" })
export type AnthropicContainerUpload = { readonly "file_id": string; readonly "type": "container_upload" }
export const AnthropicContainerUpload = Schema.Struct({
"file_id": Schema.String,
"type": Schema.Literal("container_upload")
}).annotate({ "identifier": "AnthropicContainerUpload" })
export type AnthropicDirectCaller = { readonly "type": "direct" }
export const AnthropicDirectCaller = Schema.Struct({ "type": Schema.Literal("direct") }).annotate({
"identifier": "AnthropicDirectCaller"
})
export type AnthropicFileDocumentSource = { readonly "file_id": string; readonly "type": "file" }
export const AnthropicFileDocumentSource = Schema.Struct({ "file_id": Schema.String, "type": Schema.Literal("file") })
.annotate({ "identifier": "AnthropicFileDocumentSource" })
export type AnthropicImageMimeType = "image/jpeg" | "image/png" | "image/gif" | "image/webp"
export const AnthropicImageMimeType = Schema.Literals(["image/jpeg", "image/png", "image/gif", "image/webp"]).annotate({
"identifier": "AnthropicImageMimeType"
})
export type Objects_2 = { readonly "type": "input_tokens"; readonly "value": number; readonly [x: string]: Schema.Json }
export const Objects_2 = Schema.StructWithRest(
Schema.Struct({
"type": Schema.Literal("input_tokens"),
"value": Schema.Number.check(Schema.isInt().annotate({ "expected": "an integer" }))
}),
[Schema.Record(Schema.String, Schema.Json.annotate({ "expected": "JSON value" }))]
)
export type AnthropicInputTokensTrigger = { readonly "type": "input_tokens"; readonly "value": number }
export const AnthropicInputTokensTrigger = Schema.Struct({
"type": Schema.Literal("input_tokens"),
"value": Schema.Number.check(Schema.isInt().annotate({ "expected": "an integer" }))
}).annotate({ "identifier": "AnthropicInputTokensTrigger" })
export type Objects_3 = {
readonly "ephemeral_1h_input_tokens"?: number
readonly "ephemeral_5m_input_tokens"?: number
readonly [x: string]: Schema.Json
}
export const Objects_3 = Schema.StructWithRest(
Schema.Struct({
"ephemeral_1h_input_tokens": Schema.optionalKey(
Schema.Number.check(Schema.isInt().annotate({ "expected": "an integer" }))
),
"ephemeral_5m_input_tokens": Schema.optionalKey(
Schema.Number.check(Schema.isInt().annotate({ "expected": "an integer" }))
)
}),
[Schema.Record(Schema.String, Schema.Json.annotate({ "expected": "JSON value" }))]
)
export type AnthropicOutputTokensDetails =
| { readonly "thinking_tokens": number; readonly [x: string]: Schema.Json }
| null
export const AnthropicOutputTokensDetails = Schema.Union([
Schema.StructWithRest(
Schema.Struct({ "thinking_tokens": Schema.Number.check(Schema.isInt().annotate({ "expected": "an integer" })) }),
[Schema.Record(Schema.String, Schema.Json.annotate({ "expected": "JSON value" }))]
),
Schema.Null
]).annotate({ "identifier": "AnthropicOutputTokensDetails" })
export type AnthropicPlainTextSource = {
readonly "data": string
readonly "media_type": "text/plain"
readonly "type": "text"
}
export const AnthropicPlainTextSource = Schema.Struct({
"data": Schema.String,
"media_type": Schema.Literal("text/plain"),
"type": Schema.Literal("text")
}).annotate({ "identifier": "AnthropicPlainTextSource" })
export type AnthropicRedactedThinkingBlock = { readonly "data": string; readonly "type": "redacted_thinking" }
export const AnthropicRedactedThinkingBlock = Schema.Struct({
"data": Schema.String,
"type": Schema.Literal("redacted_thinking")
}).annotate({ "identifier": "AnthropicRedactedThinkingBlock" })
export type AnthropicRefusalStopDetails = {
readonly "category": "cyber" | "bio" | null
readonly "explanation": string | null
readonly "type": "refusal"
readonly [x: string]: Schema.Json
} | null
export const AnthropicRefusalStopDetails = Schema.Union([
Schema.StructWithRest(
Schema.Struct({
"category": Schema.Union([Schema.Literal("cyber"), Schema.Literal("bio"), Schema.Null]),
"explanation": Schema.Union([Schema.String, Schema.Null]),
"type": Schema.Literal("refusal")
}),
[Schema.Record(Schema.String, Schema.Json.annotate({ "expected": "JSON value" }))]
),
Schema.Null
]).annotate({ "description": "Structured information about a refusal", "identifier": "AnthropicRefusalStopDetails" })
export type AnthropicServerToolErrorCode =
| "invalid_tool_input"
| "unavailable"
| "too_many_requests"
| "execution_time_exceeded"
export const AnthropicServerToolErrorCode = Schema.Literals([
"invalid_tool_input",
"unavailable",
"too_many_requests",
"execution_time_exceeded"
]).annotate({ "identifier": "AnthropicServerToolErrorCode" })
export type AnthropicServerToolUsage = {
readonly "web_fetch_requests": number
readonly "web_search_requests": number
readonly [x: string]: Schema.Json
} | null
export const AnthropicServerToolUsage = Schema.Union([
Schema.StructWithRest(
Schema.Struct({
"web_fetch_requests": Schema.Number.check(Schema.isInt().annotate({ "expected": "an integer" })),
"web_search_requests": Schema.Number.check(Schema.isInt().annotate({ "expected": "an integer" }))
}),
[Schema.Record(Schema.String, Schema.Json.annotate({ "expected": "JSON value" }))]
),
Schema.Null
]).annotate({ "identifier": "AnthropicServerToolUsage" })
export type AnthropicServiceTier = "standard" | "priority" | "batch" | null
export const AnthropicServiceTier = Schema.Union([
Schema.Literal("standard"),
Schema.Literal("priority"),
Schema.Literal("batch"),
Schema.Null
]).annotate({ "identifier": "AnthropicServiceTier" })
export type AnthropicSpeed = "fast" | "standard" | null
export const AnthropicSpeed = Schema.Union([Schema.Literal("fast"), Schema.Literal("standard"), Schema.Null]).annotate({
"identifier": "AnthropicSpeed"
})
export type AnthropicTextEditorCodeExecutionCreateResult = {
readonly "is_file_update": boolean
readonly "type": "text_editor_code_execution_create_result"
}
export const AnthropicTextEditorCodeExecutionCreateResult = Schema.Struct({
"is_file_update": Schema.Boolean,
"type": Schema.Literal("text_editor_code_execution_create_result")
}).annotate({ "identifier": "AnthropicTextEditorCodeExecutionCreateResult" })
export type AnthropicTextEditorCodeExecutionStrReplaceResult = {
readonly "lines": ReadonlyArray<string> | null
readonly "new_lines": number | null
readonly "new_start": number | null
readonly "old_lines": number | null
readonly "old_start": number | null
readonly "type": "text_editor_code_execution_str_replace_result"
}
export const AnthropicTextEditorCodeExecutionStrReplaceResult = Schema.Struct({
"lines": Schema.Union([Schema.Array(Schema.String), Schema.Null]),
"new_lines": Schema.Union([Schema.Number.check(Schema.isInt().annotate({ "expected": "an integer" })), Schema.Null]),
"new_start": Schema.Union([Schema.Number.check(Schema.isInt().annotate({ "expected": "an integer" })), Schema.Null]),
"old_lines": Schema.Union([Schema.Number.check(Schema.isInt().annotate({ "expected": "an integer" })), Schema.Null]),
"old_start": Schema.Union([Schema.Number.check(Schema.isInt().annotate({ "expected": "an integer" })), Schema.Null]),
"type": Schema.Literal("text_editor_code_execution_str_replace_result")
}).annotate({ "identifier": "AnthropicTextEditorCodeExecutionStrReplaceResult" })
export type AnthropicTextEditorCodeExecutionToolResultError = {
readonly "error_code":
| "invalid_tool_input"
| "unavailable"
| "too_many_requests"
| "execution_time_exceeded"
| "file_not_found"
readonly "error_message": string | null
readonly "type": "text_editor_code_execution_tool_result_error"
}
export const AnthropicTextEditorCodeExecutionToolResultError = Schema.Struct({
"error_code": Schema.Literals([
"invalid_tool_input",
"unavailable",
"too_many_requests",
"execution_time_exceeded",
"file_not_found"
]),
"error_message": Schema.Union([Schema.String, Schema.Null]),
"type": Schema.Literal("text_editor_code_execution_tool_result_error")
}).annotate({ "identifier": "AnthropicTextEditorCodeExecutionToolResultError" })
export type AnthropicTextEditorCodeExecutionViewResult = {
readonly "content": string
readonly "file_type": "text" | "image" | "pdf"
readonly "num_lines": number | null
readonly "start_line": number | null
readonly "total_lines": number | null
readonly "type": "text_editor_code_execution_view_result"
}
export const AnthropicTextEditorCodeExecutionViewResult = Schema.Struct({
"content": Schema.String,
"file_type": Schema.Literals(["text", "image", "pdf"]),
"num_lines": Schema.Union([Schema.Number.check(Schema.isInt().annotate({ "expected": "an integer" })), Schema.Null]),
"start_line": Schema.Union([Schema.Number.check(Schema.isInt().annotate({ "expected": "an integer" })), Schema.Null]),
"total_lines": Schema.Union([
Schema.Number.check(Schema.isInt().annotate({ "expected": "an integer" })),
Schema.Null
]),
"type": Schema.Literal("text_editor_code_execution_view_result")
}).annotate({ "identifier": "AnthropicTextEditorCodeExecutionViewResult" })
export type AnthropicThinkingBlock = {
readonly "signature": string
readonly "thinking": string
readonly "type": "thinking"
}
export const AnthropicThinkingBlock = Schema.Struct({
"signature": Schema.String,
"thinking": Schema.String,
"type": Schema.Literal("thinking")
}).annotate({ "identifier": "AnthropicThinkingBlock" })
export type AnthropicThinkingDisplay = "summarized" | "omitted" | null
export const AnthropicThinkingDisplay = Schema.Union([
Schema.Literal("summarized"),
Schema.Literal("omitted"),
Schema.Null
]).annotate({ "identifier": "AnthropicThinkingDisplay" })
export type AnthropicThinkingTurns = { readonly "type": "thinking_turns"; readonly "value": number }
export const AnthropicThinkingTurns = Schema.Struct({
"type": Schema.Literal("thinking_turns"),
"value": Schema.Number.check(Schema.isInt().annotate({ "expected": "an integer" }))
}).annotate({ "identifier": "AnthropicThinkingTurns" })
export type AnthropicToolReference = { readonly "tool_name": string; readonly "type": "tool_reference" }
export const AnthropicToolReference = Schema.Struct({
"tool_name": Schema.String,
"type": Schema.Literal("tool_reference")
}).annotate({ "identifier": "AnthropicToolReference" })
export type AnthropicToolUsesKeep = { readonly "type": "tool_uses"; readonly "value": number }
export const AnthropicToolUsesKeep = Schema.Struct({
"type": Schema.Literal("tool_uses"),
"value": Schema.Number.check(Schema.isInt().annotate({ "expected": "an integer" }))
}).annotate({ "identifier": "AnthropicToolUsesKeep" })
export type AnthropicToolUsesTrigger = { readonly "type": "tool_uses"; readonly "value": number }
export const AnthropicToolUsesTrigger = Schema.Struct({
"type": Schema.Literal("tool_uses"),
"value": Schema.Number.check(Schema.isInt().annotate({ "expected": "an integer" }))
}).annotate({ "identifier": "AnthropicToolUsesTrigger" })
export type AnthropicUrlImageSource = { readonly "type": "url"; readonly "url": string }
export const AnthropicUrlImageSource = Schema.Struct({ "type": Schema.Literal("url"), "url": Schema.String }).annotate({
"identifier": "AnthropicUrlImageSource"
})
export type AnthropicUrlPdfSource = { readonly "type": "url"; readonly "url": string }
export const AnthropicUrlPdfSource = Schema.Struct({ "type": Schema.Literal("url"), "url": Schema.String }).annotate({
"identifier": "AnthropicUrlPdfSource"
})
export type AnthropicWebFetchToolResultError = {
readonly "error_code":
| "invalid_tool_input"
| "url_too_long"
| "url_not_allowed"
| "url_not_accessible"
| "unsupported_content_type"
| "too_many_requests"
| "max_uses_exceeded"
| "unavailable"
readonly "type": "web_fetch_tool_result_error"
}
export const AnthropicWebFetchToolResultError = Schema.Struct({
"error_code": Schema.Literals([
"invalid_tool_input",
"url_too_long",
"url_not_allowed",
"url_not_accessible",
"unsupported_content_type",
"too_many_requests",
"max_uses_exceeded",
"unavailable"
]),
"type": Schema.Literal("web_fetch_tool_result_error")
}).annotate({ "identifier": "AnthropicWebFetchToolResultError" })
export type AnthropicWebSearchResult = {
readonly "encrypted_content": string
readonly "page_age": string | null
readonly "title": string
readonly "type": "web_search_result"
readonly "url": string
}
export const AnthropicWebSearchResult = Schema.Struct({
"encrypted_content": Schema.String,
"page_age": Schema.Union([Schema.String, Schema.Null]),
"title": Schema.String,
"type": Schema.Literal("web_search_result"),
"url": Schema.String
}).annotate({ "identifier": "AnthropicWebSearchResult" })
export type AnthropicWebSearchResultBlockParam = {
readonly "encrypted_content": string
readonly "page_age"?: string | null
readonly "title": string
readonly "type": "web_search_result"
readonly "url": string
}
export const AnthropicWebSearchResultBlockParam = Schema.Struct({
"encrypted_content": Schema.String,
"page_age": Schema.optionalKey(Schema.Union([Schema.String, Schema.Null])),
"title": Schema.String,
"type": Schema.Literal("web_search_result"),
"url": Schema.String
}).annotate({ "identifier": "AnthropicWebSearchResultBlockParam" })
export type AnthropicWebSearchToolResultError = {
readonly "error_code":
| "invalid_tool_input"
| "unavailable"
| "max_uses_exceeded"
| "too_many_requests"
| "query_too_long"
| "request_too_large"
readonly "type": "web_search_tool_result_error"
}
export const AnthropicWebSearchToolResultError = Schema.Struct({
"error_code": Schema.Literals([
"invalid_tool_input",
"unavailable",
"max_uses_exceeded",
"too_many_requests",
"query_too_long",
"request_too_large"
]),
"type": Schema.Literal("web_search_tool_result_error")
}).annotate({ "identifier": "AnthropicWebSearchToolResultError" })
export type Objects_4 = {
readonly "city"?: string | null
readonly "country"?: string | null
readonly "region"?: string | null
readonly "timezone"?: string | null
readonly "type": "approximate"
readonly [x: string]: Schema.Json
}
export const Objects_4 = Schema.StructWithRest(
Schema.Struct({
"city": Schema.optionalKey(Schema.Union([Schema.String, Schema.Null])),
"country": Schema.optionalKey(Schema.Union([Schema.String, Schema.Null])),
"region": Schema.optionalKey(Schema.Union([Schema.String, Schema.Null])),
"timezone": Schema.optionalKey(Schema.Union([Schema.String, Schema.Null])),
"type": Schema.Literal("approximate")
}),
[Schema.Record(Schema.String, Schema.Json.annotate({ "expected": "JSON value" }))]
)
export type ApiErrorType =
| "context_length_exceeded"
| "max_tokens_exceeded"
| "token_limit_exceeded"
| "string_too_long"
| "authentication"
| "permission_denied"
| "payment_required"
| "rate_limit_exceeded"
| "provider_overloaded"
| "provider_unavailable"
| "invalid_request"
| "invalid_prompt"
| "not_found"
| "precondition_failed"
| "payload_too_large"
| "unprocessable"
| "content_policy_violation"
| "refusal"
| "invalid_image"
| "image_too_large"
| "image_too_small"
| "unsupported_image_format"
| "image_not_found"
| "image_download_failed"
| "server"
| "timeout"
| "unmapped"
export const ApiErrorType = Schema.Literals([
"context_length_exceeded",
"max_tokens_exceeded",
"token_limit_exceeded",
"string_too_long",
"authentication",
"permission_denied",
"payment_required",
"rate_limit_exceeded",
"provider_overloaded",
"provider_unavailable",
"invalid_request",
"invalid_prompt",
"not_found",
"precondition_failed",
"payload_too_large",
"unprocessable",
"content_policy_violation",
"refusal",
"invalid_image",
"image_too_large",
"image_too_small",
"unsupported_image_format",
"image_not_found",
"image_download_failed",
"server",
"timeout",
"unmapped"
]).annotate({
"description": "Canonical OpenRouter error type, stable across all API formats",
"identifier": "ApiErrorType"
})
export type ApplyPatchCallOperationDiffDeltaEvent = {
readonly "delta": string
readonly "item_id": string
readonly "output_index": number
readonly "sequence_number": number
readonly "type": "response.apply_patch_call_operation_diff.delta"
}
export const ApplyPatchCallOperationDiffDeltaEvent = Schema.Struct({
"delta": Schema.String,
"item_id": Schema.String,
"output_index": Schema.Number.check(Schema.isInt().annotate({ "expected": "an integer" })),
"sequence_number": Schema.Number.check(Schema.isInt().annotate({ "expected": "an integer" })),
"type": Schema.Literal("response.apply_patch_call_operation_diff.delta")
}).annotate({
"description": "Incremental chunk of `operation.diff` for an `apply_patch_call`. Matches OpenAI's streaming shape.",
"identifier": "ApplyPatchCallOperationDiffDeltaEvent"
})
export type ApplyPatchCallOperationDiffDoneEvent = {
readonly "diff": string
readonly "item_id": string
readonly "output_index": number
readonly "sequence_number": number
readonly "type": "response.apply_patch_call_operation_diff.done"
}
export const ApplyPatchCallOperationDiffDoneEvent = Schema.Struct({
"diff": Schema.String,
"item_id": Schema.String,
"output_index": Schema.Number.check(Schema.isInt().annotate({ "expected": "an integer" })),
"sequence_number": Schema.Number.check(Schema.isInt().annotate({ "expected": "an integer" })),
"type": Schema.Literal("response.apply_patch_call_operation_diff.done")
}).annotate({
"description": "Emitted when `operation.diff` streaming completes for an `apply_patch_call`.",
"identifier": "ApplyPatchCallOperationDiffDoneEvent"
})
export type ApplyPatchCallOutputItem = {
readonly "call_id": string
readonly "id"?: string | null
readonly "output"?: string | null
readonly "status": "completed" | "failed"
readonly "type": "apply_patch_call_output"
}
export const ApplyPatchCallOutputItem = Schema.Struct({
"call_id": Schema.String,
"id": Schema.optionalKey(Schema.Union([Schema.String, Schema.Null])),
"output": Schema.optionalKey(Schema.Union([Schema.String, Schema.Null])),
"status": Schema.Literals(["completed", "failed"]),
"type": Schema.Literal("apply_patch_call_output")
}).annotate({
"description":
"The client's echo of an `apply_patch_call` after applying the patch. `output` is an optional human-readable log; `status` is `completed` when the patch was applied successfully, `failed` otherwise.",
"identifier": "ApplyPatchCallOutputItem"
})
export type ApplyPatchCallStatus = "in_progress" | "completed"
export const ApplyPatchCallStatus = Schema.Literals(["in_progress", "completed"]).annotate({
"description": "Lifecycle state of an `apply_patch_call` output item.",
"identifier": "ApplyPatchCallStatus"
})
export type ApplyPatchCreateFileOperation = {
readonly "diff": string
readonly "path": string
readonly "type": "create_file"
}
export const ApplyPatchCreateFileOperation = Schema.Struct({
"diff": Schema.String,
"path": Schema.String,
"type": Schema.Literal("create_file")
}).annotate({
"description":
"The `create_file` variant of an `apply_patch_call.operation`. Carries a V4A diff describing the new file contents.",
"identifier": "ApplyPatchCreateFileOperation"
})
export type ApplyPatchDeleteFileOperation = { readonly "path": string; readonly "type": "delete_file" }
export const ApplyPatchDeleteFileOperation = Schema.Struct({
"path": Schema.String,
"type": Schema.Literal("delete_file")
}).annotate({
"description":
"The `delete_file` variant of an `apply_patch_call.operation`. Identifies the file to remove; no diff is required.",
"identifier": "ApplyPatchDeleteFileOperation"
})
export type ApplyPatchEngineEnum = "auto" | "native" | "openrouter"
export const ApplyPatchEngineEnum = Schema.Literals(["auto", "native", "openrouter"]).annotate({
"description":
"Which apply_patch engine to use. \"auto\" (default) uses native passthrough when the endpoint advertises native apply_patch support, otherwise falls back to OpenRouter's HITL validator. \"native\" forces native passthrough — when the endpoint does not support native, the request falls back to HITL. \"openrouter\" always runs the HITL validator. Native passthrough streams the diff incrementally via `apply_patch_call_operation_diff.delta` events; HITL buffers the diff for atomic delivery as a single delta.",
"identifier": "ApplyPatchEngineEnum"
})
export type ApplyPatchServerTool = { readonly "type": "apply_patch" }
export const ApplyPatchServerTool = Schema.Struct({ "type": Schema.Literal("apply_patch") }).annotate({
"description": "Apply patch tool configuration",
"identifier": "ApplyPatchServerTool"
})
export type ApplyPatchUpdateFileOperation = {
readonly "diff": string
readonly "path": string
readonly "type": "update_file"
}
export const ApplyPatchUpdateFileOperation = Schema.Struct({
"diff": Schema.String,
"path": Schema.String,
"type": Schema.Literal("update_file")
}).annotate({
"description":
"The `update_file` variant of an `apply_patch_call.operation`. Carries a V4A diff describing edits to an existing file.",
"identifier": "ApplyPatchUpdateFileOperation"
})
export type AppRankingsItem = {
readonly "app_id": number
readonly "app_name": string
readonly "rank": number
readonly "total_requests": number
readonly "total_tokens": string
}
export const AppRankingsItem = Schema.Struct({
"app_id": Schema.Number.annotate({ "description": "Stable numeric identifier of the app on OpenRouter." }).check(
Schema.isInt().annotate({ "expected": "an integer" })
),
"app_name": Schema.String.annotate({ "description": "Public display name of the app." }),
"rank": Schema.Number.annotate({
"description": "1-based position of the app within this response, per the requested `sort`."
}).check(Schema.isInt().annotate({ "expected": "an integer" })),
"total_requests": Schema.Number.annotate({
"description": "Number of requests attributed to the app inside the date window."
}).check(Schema.isInt().annotate({ "expected": "an integer" })),
"total_tokens": Schema.String.annotate({
"description":
"Sum of `prompt_tokens + completion_tokens` attributed to the app inside the date window, returned as a decimal string so 64-bit values are not truncated."
})
}).annotate({ "identifier": "AppRankingsItem" })
export type AutoBetaRouterPlugin = {
readonly "allowed_models"?: ReadonlyArray<string>
readonly "cost_quality_tradeoff"?: number
readonly "enabled"?: boolean
readonly "id": "auto-beta-router"
}
export const AutoBetaRouterPlugin = Schema.Struct({
"allowed_models": Schema.optionalKey(
Schema.Array(Schema.String).annotate({
"description":
"List of model patterns to filter which models the auto-beta-router can route between. Supports wildcards (e.g., \"anthropic/*\" matches all Anthropic models). When not specified, uses the default supported models list."
})
),
"cost_quality_tradeoff": Schema.optionalKey(
Schema.Number.annotate({
"description":
"Balances routing between cost and quality on a 0-10 scale. The auto-beta-router ranks models for the classified task type by community spend share, then filters candidates by their average cost per generation for that task. Higher values favor cheaper models: 10 keeps only models around the cheapest 10th percentile, while 0 permits models up to the 90th percentile for cost. Defaults to 9."
}).check(Schema.isInt().annotate({ "expected": "an integer" })).check(
Schema.isGreaterThanOrEqualTo(0).annotate({ "expected": "a value greater than or equal to 0" })
).check(Schema.isLessThanOrEqualTo(10).annotate({ "expected": "a value less than or equal to 10" }))
),
"enabled": Schema.optionalKey(
Schema.Boolean.annotate({
"description": "Set to false to disable the auto-beta-router plugin for this request. Defaults to true."
})
),
"id": Schema.Literal("auto-beta-router")
}).annotate({ "identifier": "AutoBetaRouterPlugin" })
export type AutoRouterPlugin = {
readonly "allowed_models"?: ReadonlyArray<string>
readonly "cost_quality_tradeoff"?: number
readonly "enabled"?: boolean
readonly "id": "auto-router"
readonly "pin_model"?: boolean
}
export const AutoRouterPlugin = Schema.Struct({
"allowed_models": Schema.optionalKey(
Schema.Array(Schema.String).annotate({
"description":
"List of model patterns to filter which models the auto-router can route between. Supports wildcards (e.g., \"anthropic/*\" matches all Anthropic models). When not specified, uses the default supported models list."
})
),
"cost_quality_tradeoff": Schema.optionalKey(
Schema.Number.annotate({
"description":
"Controls cost vs. quality routing tradeoff (0–10). 0 = pure quality (best model regardless of cost), 10 = maximize for cost (cheapest model wins). Intermediate values blend quality and cost signals continuously. Defaults to 7."
}).check(Schema.isInt().annotate({ "expected": "an integer" })).check(
Schema.isGreaterThanOrEqualTo(0).annotate({ "expected": "a value greater than or equal to 0" })
).check(Schema.isLessThanOrEqualTo(10).annotate({ "expected": "a value less than or equal to 10" }))
),
"enabled": Schema.optionalKey(
Schema.Boolean.annotate({
"description": "Set to false to disable the auto-router plugin for this request. Defaults to true."
})
),
"id": Schema.Literal("auto-router"),
"pin_model": Schema.optionalKey(
Schema.Boolean.annotate({
"description":
"When true, reuses the model from the most recent assistant message's `model` attribute for subsequent turns. Defaults to false."
})
)
}).annotate({ "identifier": "AutoRouterPlugin" })
export type BadGatewayResponseErrorData = {
readonly "code": number
readonly "message": string
readonly "metadata"?: { readonly [x: string]: Schema.Json } | null
}
export const BadGatewayResponseErrorData = Schema.Struct({
"code": Schema.Number.check(Schema.isInt().annotate({ "expected": "an integer" })),
"message": Schema.String,
"metadata": Schema.optionalKey(
Schema.Union([Schema.Record(Schema.String, Schema.Json.annotate({ "expected": "JSON value" })), Schema.Null])
)
}).annotate({ "description": "Error data for BadGatewayResponse", "identifier": "BadGatewayResponseErrorData" })
export type BadRequestResponseErrorData = {
readonly "code": number
readonly "message": string
readonly "metadata"?: { readonly [x: string]: Schema.Json } | null
}
export const BadRequestResponseErrorData = Schema.Struct({
"code": Schema.Number.check(Schema.isInt().annotate({ "expected": "an integer" })),
"message": Schema.String,
"metadata": Schema.optionalKey(
Schema.Union([Schema.Record(Schema.String, Schema.Json.annotate({ "expected": "JSON value" })), Schema.Null])
)
}).annotate({ "description": "Error data for BadRequestResponse", "identifier": "BadRequestResponseErrorData" })
export type BaseCustomToolCallInputDeltaEvent = {
readonly "delta": string
readonly "item_id": string
readonly "output_index": number
readonly "sequence_number": number
readonly "type": "response.custom_tool_call_input.delta"
}
export const BaseCustomToolCallInputDeltaEvent = Schema.Struct({
"delta": Schema.String,
"item_id": Schema.String,
"output_index": Schema.Number.check(Schema.isInt().annotate({ "expected": "an integer" })),
"sequence_number": Schema.Number.check(Schema.isInt().annotate({ "expected": "an integer" })),
"type": Schema.Literal("response.custom_tool_call_input.delta")
}).annotate({
"description":
"Event emitted when a custom tool call's freeform input is being streamed. Mirrors `response.function_call_arguments.delta` but for `custom` tools whose input is opaque text rather than JSON arguments.",
"identifier": "BaseCustomToolCallInputDeltaEvent"
})
export type BaseCustomToolCallInputDoneEvent = {
readonly "input": string
readonly "item_id": string
readonly "output_index": number
readonly "sequence_number": number
readonly "type": "response.custom_tool_call_input.done"
}
export const BaseCustomToolCallInputDoneEvent = Schema.Struct({
"input": Schema.String,
"item_id": Schema.String,
"output_index": Schema.Number.check(Schema.isInt().annotate({ "expected": "an integer" })),
"sequence_number": Schema.Number.check(Schema.isInt().annotate({ "expected": "an integer" })),
"type": Schema.Literal("response.custom_tool_call_input.done")
}).annotate({
"description":
"Event emitted when a custom tool call's freeform input streaming is complete. Mirrors `response.function_call_arguments.done` but for `custom` tools.",
"identifier": "BaseCustomToolCallInputDoneEvent"
})
export type BaseErrorEvent = {
readonly "code": string | null
readonly "message": string
readonly "param": string | null
readonly "sequence_number": number
readonly "type": "error"
}
export const BaseErrorEvent = Schema.Struct({
"code": Schema.Union([Schema.String, Schema.Null]),
"message": Schema.String,
"param": Schema.Union([Schema.String, Schema.Null]),
"sequence_number": Schema.Number.check(Schema.isInt().annotate({ "expected": "an integer" })),
"type": Schema.Literal("error")
}).annotate({ "description": "Event emitted when an error occurs during streaming", "identifier": "BaseErrorEvent" })
export type BaseFunctionCallArgsDeltaEvent = {
readonly "delta": string
readonly "item_id": string
readonly "output_index": number
readonly "sequence_number": number
readonly "type": "response.function_call_arguments.delta"
}
export const BaseFunctionCallArgsDeltaEvent = Schema.Struct({
"delta": Schema.String,
"item_id": Schema.String,
"output_index": Schema.Number.check(Schema.isInt().annotate({ "expected": "an integer" })),
"sequence_number": Schema.Number.check(Schema.isInt().annotate({ "expected": "an integer" })),
"type": Schema.Literal("response.function_call_arguments.delta")
}).annotate({
"description": "Event emitted when function call arguments are being streamed",
"identifier": "BaseFunctionCallArgsDeltaEvent"
})
export type BaseFunctionCallArgsDoneEvent = {
readonly "arguments": string
readonly "item_id": string
readonly "name": string
readonly "output_index": number
readonly "sequence_number": number
readonly "type": "response.function_call_arguments.done"
}
export const BaseFunctionCallArgsDoneEvent = Schema.Struct({
"arguments": Schema.String,
"item_id": Schema.String,
"name": Schema.String,
"output_index": Schema.Number.check(Schema.isInt().annotate({ "expected": "an integer" })),
"sequence_number": Schema.Number.check(Schema.isInt().annotate({ "expected": "an integer" })),
"type": Schema.Literal("response.function_call_arguments.done")
}).annotate({
"description": "Event emitted when function call arguments streaming is complete",
"identifier": "BaseFunctionCallArgsDoneEvent"
})
export type BaseReasoningDeltaEvent = {
readonly "content_index": number
readonly "delta": string
readonly "item_id": string
readonly "output_index": number
readonly "sequence_number": number
readonly "type": "response.reasoning_text.delta"
}
export const BaseReasoningDeltaEvent = Schema.Struct({
"content_index": Schema.Number.check(Schema.isInt().annotate({ "expected": "an integer" })),
"delta": Schema.String,
"item_id": Schema.String,
"output_index": Schema.Number.check(Schema.isInt().annotate({ "expected": "an integer" })),
"sequence_number": Schema.Number.check(Schema.isInt().annotate({ "expected": "an integer" })),
"type": Schema.Literal("response.reasoning_text.delta")
}).annotate({
"description": "Event emitted when reasoning text delta is streamed",
"identifier": "BaseReasoningDeltaEvent"
})
export type BaseReasoningDoneEvent = {
readonly "content_index": number
readonly "item_id": string
readonly "output_index": number
readonly "sequence_number": number
readonly "text": string
readonly "type": "response.reasoning_text.done"
}
export const BaseReasoningDoneEvent = Schema.Struct({
"content_index": Schema.Number.check(Schema.isInt().annotate({ "expected": "an integer" })),
"item_id": Schema.String,
"output_index": Schema.Number.check(Schema.isInt().annotate({ "expected": "an integer" })),
"sequence_number": Schema.Number.check(Schema.isInt().annotate({ "expected": "an integer" })),
"text": Schema.String,
"type": Schema.Literal("response.reasoning_text.done")
}).annotate({
"description": "Event emitted when reasoning text streaming is complete",
"identifier": "BaseReasoningDoneEvent"
})
export type BaseReasoningSummaryTextDeltaEvent = {
readonly "delta": string
readonly "item_id": string
readonly "output_index": number
readonly "sequence_number": number
readonly "summary_index": number
readonly "type": "response.reasoning_summary_text.delta"
}
export const BaseReasoningSummaryTextDeltaEvent = Schema.Struct({
"delta": Schema.String,
"item_id": Schema.String,
"output_index": Schema.Number.check(Schema.isInt().annotate({ "expected": "an integer" })),
"sequence_number": Schema.Number.check(Schema.isInt().annotate({ "expected": "an integer" })),
"summary_index": Schema.Number.check(Schema.isInt().annotate({ "expected": "an integer" })),
"type": Schema.Literal("response.reasoning_summary_text.delta")
}).annotate({
"description": "Event emitted when reasoning summary text delta is streamed",
"identifier": "BaseReasoningSummaryTextDeltaEvent"
})
export type BaseReasoningSummaryTextDoneEvent = {
readonly "item_id": string
readonly "output_index": number
readonly "sequence_number": number
readonly "summary_index": number
readonly "text": string
readonly "type": "response.reasoning_summary_text.done"
}
export const BaseReasoningSummaryTextDoneEvent = Schema.Struct({
"item_id": Schema.String,
"output_index": Schema.Number.check(Schema.isInt().annotate({ "expected": "an integer" })),
"sequence_number": Schema.Number.check(Schema.isInt().annotate({ "expected": "an integer" })),
"summary_index": Schema.Number.check(Schema.isInt().annotate({ "expected": "an integer" })),
"text": Schema.String,
"type": Schema.Literal("response.reasoning_summary_text.done")
}).annotate({
"description": "Event emitted when reasoning summary text streaming is complete",
"identifier": "BaseReasoningSummaryTextDoneEvent"
})
export type BaseRefusalDeltaEvent = {
readonly "content_index": number
readonly "delta": string
readonly "item_id": string
readonly "output_index": number
readonly "sequence_number": number
readonly "type": "response.refusal.delta"
}
export const BaseRefusalDeltaEvent = Schema.Struct({
"content_index": Schema.Number.check(Schema.isInt().annotate({ "expected": "an integer" })),
"delta": Schema.String,
"item_id": Schema.String,
"output_index": Schema.Number.check(Schema.isInt().annotate({ "expected": "an integer" })),
"sequence_number": Schema.Number.check(Schema.isInt().annotate({ "expected": "an integer" })),
"type": Schema.Literal("response.refusal.delta")
}).annotate({ "description": "Event emitted when a refusal delta is streamed", "identifier": "BaseRefusalDeltaEvent" })
export type BaseRefusalDoneEvent = {
readonly "content_index": number
readonly "item_id": string
readonly "output_index": number
readonly "refusal": string
readonly "sequence_number": number
readonly "type": "response.refusal.done"
}
export const BaseRefusalDoneEvent = Schema.Struct({
"content_index": Schema.Number.check(Schema.isInt().annotate({ "expected": "an integer" })),
"item_id": Schema.String,
"output_index": Schema.Number.check(Schema.isInt().annotate({ "expected": "an integer" })),
"refusal": Schema.String,
"sequence_number": Schema.Number.check(Schema.isInt().annotate({ "expected": "an integer" })),
"type": Schema.Literal("response.refusal.done")
}).annotate({ "description": "Event emitted when refusal streaming is complete", "identifier": "BaseRefusalDoneEvent" })
export type BashServerToolEngine = "auto" | "native" | "openrouter"
export const BashServerToolEngine = Schema.Literals(["auto", "native", "openrouter"]).annotate({
"description":
"Which bash engine to use. \"openrouter\" runs commands server-side in the OpenRouter sandbox. \"auto\" (default) and \"native\" use native passthrough, returning the tool call to your application to run client-side; OpenRouter does not execute the commands.",
"identifier": "BashServerToolEngine"
})
export type BooleanCapability = { readonly "type": "boolean" }
export const BooleanCapability = Schema.Struct({ "type": Schema.Literal("boolean") }).annotate({
"description": "A supported-or-not flag. Present means the parameter is accepted.",
"identifier": "BooleanCapability"
})
export type BulkAddWorkspaceMembersRequest = { readonly "user_ids": ReadonlyArray<string> }
export const BulkAddWorkspaceMembersRequest = Schema.Struct({
"user_ids": Schema.Array(Schema.String).annotate({
"description":
"List of user IDs to add to the workspace. Members are assigned the same role they hold in the organization."
}).check(Schema.isMinLength(1).annotate({ "expected": "a value with a length of at least 1" })).check(
Schema.isMaxLength(100).annotate({ "expected": "a value with a length of at most 100" })
)
}).annotate({ "identifier": "BulkAddWorkspaceMembersRequest" })
export type BulkAssignKeysRequest = { readonly "key_hashes": ReadonlyArray<string> }
export const BulkAssignKeysRequest = Schema.Struct({
"key_hashes": Schema.Array(
Schema.String.check(Schema.isMinLength(1).annotate({ "expected": "a value with a length of at least 1" }))
).annotate({ "description": "Array of API key hashes to assign to the guardrail" }).check(
Schema.isMinLength(1).annotate({ "expected": "a value with a length of at least 1" })
)
}).annotate({ "identifier": "BulkAssignKeysRequest" })
export type BulkAssignKeysResponse = { readonly "assigned_count": number }
export const BulkAssignKeysResponse = Schema.Struct({
"assigned_count": Schema.Number.annotate({ "description": "Number of keys successfully assigned" }).check(
Schema.isInt().annotate({ "expected": "an integer" })
)
}).annotate({ "identifier": "BulkAssignKeysResponse" })
export type BulkAssignMembersRequest = { readonly "member_user_ids": ReadonlyArray<string> }
export const BulkAssignMembersRequest = Schema.Struct({
"member_user_ids": Schema.Array(
Schema.String.check(Schema.isMinLength(1).annotate({ "expected": "a value with a length of at least 1" }))
).annotate({ "description": "Array of member user IDs to assign to the guardrail" }).check(
Schema.isMinLength(1).annotate({ "expected": "a value with a length of at least 1" })
)
}).annotate({ "identifier": "BulkAssignMembersRequest" })
export type BulkAssignMembersResponse = { readonly "assigned_count": number }
export const BulkAssignMembersResponse = Schema.Struct({
"assigned_count": Schema.Number.annotate({ "description": "Number of members successfully assigned" }).check(
Schema.isInt().annotate({ "expected": "an integer" })
)
}).annotate({ "identifier": "BulkAssignMembersResponse" })
export type BulkRemoveWorkspaceMembersRequest = { readonly "user_ids": ReadonlyArray<string> }
export const BulkRemoveWorkspaceMembersRequest = Schema.Struct({
"user_ids": Schema.Array(Schema.String).annotate({ "description": "List of user IDs to remove from the workspace" })
.check(Schema.isMinLength(1).annotate({ "expected": "a value with a length of at least 1" })).check(
Schema.isMaxLength(100).annotate({ "expected": "a value with a length of at most 100" })
)
}).annotate({ "identifier": "BulkRemoveWorkspaceMembersRequest" })
export type BulkRemoveWorkspaceMembersResponse = { readonly "removed_count": number }
export const BulkRemoveWorkspaceMembersResponse = Schema.Struct({
"removed_count": Schema.Number.annotate({ "description": "Number of members removed" }).check(
Schema.isInt().annotate({ "expected": "an integer" })
)
}).annotate({ "identifier": "BulkRemoveWorkspaceMembersResponse" })
export type BulkUnassignKeysRequest = { readonly "key_hashes": ReadonlyArray<string> }
export const BulkUnassignKeysRequest = Schema.Struct({
"key_hashes": Schema.Array(
Schema.String.check(Schema.isMinLength(1).annotate({ "expected": "a value with a length of at least 1" }))
).annotate({ "description": "Array of API key hashes to unassign from the guardrail" }).check(
Schema.isMinLength(1).annotate({ "expected": "a value with a length of at least 1" })
)
}).annotate({ "identifier": "BulkUnassignKeysRequest" })
export type BulkUnassignKeysResponse = { readonly "unassigned_count": number }
export const BulkUnassignKeysResponse = Schema.Struct({
"unassigned_count": Schema.Number.annotate({ "description": "Number of keys successfully unassigned" }).check(
Schema.isInt().annotate({ "expected": "an integer" })
)
}).annotate({ "identifier": "BulkUnassignKeysResponse" })
export type BulkUnassignMembersRequest = { readonly "member_user_ids": ReadonlyArray<string> }
export const BulkUnassignMembersRequest = Schema.Struct({
"member_user_ids": Schema.Array(
Schema.String.check(Schema.isMinLength(1).annotate({ "expected": "a value with a length of at least 1" }))
).annotate({ "description": "Array of member user IDs to unassign from the guardrail" }).check(
Schema.isMinLength(1).annotate({ "expected": "a value with a length of at least 1" })
)
}).annotate({ "identifier": "BulkUnassignMembersRequest" })
export type BulkUnassignMembersResponse = { readonly "unassigned_count": number }
export const BulkUnassignMembersResponse = Schema.Struct({
"unassigned_count": Schema.Number.annotate({ "description": "Number of members successfully unassigned" }).check(
Schema.isInt().annotate({ "expected": "an integer" })
)
}).annotate({ "identifier": "BulkUnassignMembersResponse" })
export type BYOKProviderSlug =
| "ai21"
| "aion-labs"
| "akashml"
| "alibaba"
| "amazon-bedrock"
| "amazon-nova"
| "ambient"
| "anthropic"
| "arcee-ai"
| "atlas-cloud"
| "avian"
| "azure"
| "baidu"
| "baseten"
| "black-forest-labs"
| "byteplus"
| "cerebras"
| "chutes"
| "cirrascale"
| "clarifai"
| "cloudflare"
| "cohere"
| "coreweave"
| "crusoe"
| "darkbloom"
| "decart"
| "deepgram"
| "deepinfra"
| "deepseek"
| "dekallm"
| "digitalocean"
| "featherless"
| "fireworks"
| "fish-audio"
| "friendli"
| "gmicloud"
| "google-ai-studio"
| "google-vertex"
| "groq"
| "heygen"
| "inception"
| "inceptron"
| "inferact-vllm"
| "inference-net"
| "infermatic"
| "inflection"
| "io-net"
| "ionstream"
| "krea"
| "liquid"
| "mancer"
| "mara"
| "meta"
| "minimax"
| "mistral"
| "modelrun"
| "modular"
| "moonshotai"
| "morph"
| "ncompass"
| "nebius"
| "nex-agi"
| "nextbit"
| "novita"
| "nvidia"
| "open-inference"
| "openai"
| "parasail"
| "perceptron"
| "perplexity"
| "phala"
| "poolside"
| "quiver"
| "recraft"
| "reka"
| "relace"
| "runway"
| "sail-research"
| "sakana"
| "sambanova"
| "seed"
| "siliconflow"
| "sourceful"
| "stepfun"
| "streamlake"
| "switchpoint"
| "tencent"
| "tenstorrent"
| "together"
| "upstage"
| "venice"
| "wafer"
| "wandb"
| "xai"
| "xiaomi"
| "z-ai"
export const BYOKProviderSlug = Schema.Literals([
"ai21",
"aion-labs",
"akashml",
"alibaba",
"amazon-bedrock",
"amazon-nova",
"ambient",
"anthropic",
"arcee-ai",
"atlas-cloud",
"avian",
"azure",
"baidu",
"baseten",
"black-forest-labs",
"byteplus",
"cerebras",
"chutes",
"cirrascale",
"clarifai",
"cloudflare",
"cohere",
"coreweave",
"crusoe",
"darkbloom",
"decart",
"deepgram",
"deepinfra",
"deepseek",
"dekallm",
"digitalocean",
"featherless",
"fireworks",
"fish-audio",
"friendli",
"gmicloud",
"google-ai-studio",
"google-vertex",
"groq",
"heygen",
"inception",
"inceptron",
"inferact-vllm",
"inference-net",
"infermatic",
"inflection",
"io-net",
"ionstream",
"krea",
"liquid",
"mancer",
"mara",
"meta",
"minimax",
"mistral",
"modelrun",
"modular",
"moonshotai",
"morph",
"ncompass",
"nebius",
"nex-agi",
"nextbit",
"novita",
"nvidia",
"open-inference",
"openai",
"parasail",
"perceptron",
"perplexity",
"phala",
"poolside",
"quiver",
"recraft",
"reka",
"relace",
"runway",
"sail-research",
"sakana",
"sambanova",
"seed",
"siliconflow",
"sourceful",
"stepfun",
"streamlake",
"switchpoint",
"tencent",
"tenstorrent",
"together",
"upstage",
"venice",
"wafer",
"wandb",
"xai",
"xiaomi",
"z-ai"
]).annotate({
"description":
"The upstream provider this credential authenticates against, as a lowercase slug (e.g. `openai`, `anthropic`, `amazon-bedrock`).",
"identifier": "BYOKProviderSlug"
})
export type ChatAssistantImages = ReadonlyArray<{ readonly "image_url": { readonly "url": string } }>
export const ChatAssistantImages = Schema.Array(
Schema.Struct({
"image_url": Schema.Struct({
"url": Schema.String.annotate({ "description": "URL or base64-encoded data of the generated image" })
})
})
).annotate({ "description": "Generated images from image generation models", "identifier": "ChatAssistantImages" })
export type ChatAudioOutput = {
readonly "data"?: string
readonly "expires_at"?: number
readonly "id"?: string
readonly "transcript"?: string
}
export const ChatAudioOutput = Schema.Struct({
"data": Schema.optionalKey(Schema.String.annotate({ "description": "Base64 encoded audio data" })),
"expires_at": Schema.optionalKey(
Schema.Number.annotate({ "description": "Audio expiration timestamp" }).check(
Schema.isInt().annotate({ "expected": "an integer" })
)
),
"id": Schema.optionalKey(Schema.String.annotate({ "description": "Audio output identifier" })),
"transcript": Schema.optionalKey(Schema.String.annotate({ "description": "Audio transcript" }))
}).annotate({ "description": "Audio output data or reference", "identifier": "ChatAudioOutput" })
export type ChatContentAudio = {
readonly "input_audio": { readonly "data": string; readonly "format": string }
readonly "type": "input_audio"
}
export const ChatContentAudio = Schema.Struct({
"input_audio": Schema.Struct({
"data": Schema.String.annotate({ "description": "Base64 encoded audio data" }),
"format": Schema.String.annotate({
"description":
"Audio format (e.g., wav, mp3, flac, m4a, ogg, aiff, aac, pcm16, pcm24). Supported formats vary by provider."
})
}),
"type": Schema.Literal("input_audio")
}).annotate({
"description": "Audio input content part. Supported audio formats vary by provider.",
"identifier": "ChatContentAudio"
})
export type ChatContentFile = {
readonly "file": { readonly "file_data"?: string; readonly "file_id"?: string; readonly "filename"?: string }
readonly "type": "file"
}
export const ChatContentFile = Schema.Struct({