constants.go

  1// File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details.
  2
  3package constant
  4
  5import (
  6	"encoding/json"
  7)
  8
  9// ModelNonStreamingTokens defines the maximum tokens for models that should limit
 10// non-streaming requests.
 11var ModelNonStreamingTokens = map[string]int{
 12	"claude-opus-4-20250514":                8192,
 13	"claude-4-opus-20250514":                8192,
 14	"claude-opus-4-0":                       8192,
 15	"anthropic.claude-opus-4-20250514-v1:0": 8192,
 16	"claude-opus-4@20250514":                8192,
 17}
 18
 19type Constant[T any] interface {
 20	Default() T
 21}
 22
 23// ValueOf gives the default value of a constant from its type. It's helpful when
 24// constructing constants as variants in a one-of. Note that empty structs are
 25// marshalled by default. Usage: constant.ValueOf[constant.Foo]()
 26func ValueOf[T Constant[T]]() T {
 27	var t T
 28	return t.Default()
 29}
 30
 31type Any string                          // Always "any"
 32type APIError string                     // Always "api_error"
 33type ApplicationPDF string               // Always "application/pdf"
 34type Approximate string                  // Always "approximate"
 35type Assistant string                    // Always "assistant"
 36type AuthenticationError string          // Always "authentication_error"
 37type Auto string                         // Always "auto"
 38type Base64 string                       // Always "base64"
 39type Bash string                         // Always "bash"
 40type Bash20241022 string                 // Always "bash_20241022"
 41type Bash20250124 string                 // Always "bash_20250124"
 42type BillingError string                 // Always "billing_error"
 43type Canceled string                     // Always "canceled"
 44type CharLocation string                 // Always "char_location"
 45type CitationsDelta string               // Always "citations_delta"
 46type CodeExecution string                // Always "code_execution"
 47type CodeExecution20250522 string        // Always "code_execution_20250522"
 48type CodeExecutionOutput string          // Always "code_execution_output"
 49type CodeExecutionResult string          // Always "code_execution_result"
 50type CodeExecutionToolResult string      // Always "code_execution_tool_result"
 51type CodeExecutionToolResultError string // Always "code_execution_tool_result_error"
 52type Completion string                   // Always "completion"
 53type Computer string                     // Always "computer"
 54type Computer20241022 string             // Always "computer_20241022"
 55type Computer20250124 string             // Always "computer_20250124"
 56type ContainerUpload string              // Always "container_upload"
 57type Content string                      // Always "content"
 58type ContentBlockDelta string            // Always "content_block_delta"
 59type ContentBlockLocation string         // Always "content_block_location"
 60type ContentBlockStart string            // Always "content_block_start"
 61type ContentBlockStop string             // Always "content_block_stop"
 62type Disabled string                     // Always "disabled"
 63type Document string                     // Always "document"
 64type Enabled string                      // Always "enabled"
 65type Ephemeral string                    // Always "ephemeral"
 66type Error string                        // Always "error"
 67type Errored string                      // Always "errored"
 68type Expired string                      // Always "expired"
 69type File string                         // Always "file"
 70type Image string                        // Always "image"
 71type InputJSONDelta string               // Always "input_json_delta"
 72type InvalidRequestError string          // Always "invalid_request_error"
 73type MCPToolResult string                // Always "mcp_tool_result"
 74type MCPToolUse string                   // Always "mcp_tool_use"
 75type Message string                      // Always "message"
 76type MessageBatch string                 // Always "message_batch"
 77type MessageBatchDeleted string          // Always "message_batch_deleted"
 78type MessageDelta string                 // Always "message_delta"
 79type MessageStart string                 // Always "message_start"
 80type MessageStop string                  // Always "message_stop"
 81type Model string                        // Always "model"
 82type None string                         // Always "none"
 83type NotFoundError string                // Always "not_found_error"
 84type Object string                       // Always "object"
 85type OverloadedError string              // Always "overloaded_error"
 86type PageLocation string                 // Always "page_location"
 87type PermissionError string              // Always "permission_error"
 88type RateLimitError string               // Always "rate_limit_error"
 89type RedactedThinking string             // Always "redacted_thinking"
 90type ServerToolUse string                // Always "server_tool_use"
 91type SignatureDelta string               // Always "signature_delta"
 92type StrReplaceBasedEditTool string      // Always "str_replace_based_edit_tool"
 93type StrReplaceEditor string             // Always "str_replace_editor"
 94type Succeeded string                    // Always "succeeded"
 95type Text string                         // Always "text"
 96type TextDelta string                    // Always "text_delta"
 97type TextEditor20241022 string           // Always "text_editor_20241022"
 98type TextEditor20250124 string           // Always "text_editor_20250124"
 99type TextEditor20250429 string           // Always "text_editor_20250429"
100type TextPlain string                    // Always "text/plain"
101type Thinking string                     // Always "thinking"
102type ThinkingDelta string                // Always "thinking_delta"
103type TimeoutError string                 // Always "timeout_error"
104type Tool string                         // Always "tool"
105type ToolResult string                   // Always "tool_result"
106type ToolUse string                      // Always "tool_use"
107type URL string                          // Always "url"
108type WebSearch string                    // Always "web_search"
109type WebSearch20250305 string            // Always "web_search_20250305"
110type WebSearchResult string              // Always "web_search_result"
111type WebSearchResultLocation string      // Always "web_search_result_location"
112type WebSearchToolResult string          // Always "web_search_tool_result"
113type WebSearchToolResultError string     // Always "web_search_tool_result_error"
114
115func (c Any) Default() Any                                     { return "any" }
116func (c APIError) Default() APIError                           { return "api_error" }
117func (c ApplicationPDF) Default() ApplicationPDF               { return "application/pdf" }
118func (c Approximate) Default() Approximate                     { return "approximate" }
119func (c Assistant) Default() Assistant                         { return "assistant" }
120func (c AuthenticationError) Default() AuthenticationError     { return "authentication_error" }
121func (c Auto) Default() Auto                                   { return "auto" }
122func (c Base64) Default() Base64                               { return "base64" }
123func (c Bash) Default() Bash                                   { return "bash" }
124func (c Bash20241022) Default() Bash20241022                   { return "bash_20241022" }
125func (c Bash20250124) Default() Bash20250124                   { return "bash_20250124" }
126func (c BillingError) Default() BillingError                   { return "billing_error" }
127func (c Canceled) Default() Canceled                           { return "canceled" }
128func (c CharLocation) Default() CharLocation                   { return "char_location" }
129func (c CitationsDelta) Default() CitationsDelta               { return "citations_delta" }
130func (c CodeExecution) Default() CodeExecution                 { return "code_execution" }
131func (c CodeExecution20250522) Default() CodeExecution20250522 { return "code_execution_20250522" }
132func (c CodeExecutionOutput) Default() CodeExecutionOutput     { return "code_execution_output" }
133func (c CodeExecutionResult) Default() CodeExecutionResult     { return "code_execution_result" }
134func (c CodeExecutionToolResult) Default() CodeExecutionToolResult {
135	return "code_execution_tool_result"
136}
137func (c CodeExecutionToolResultError) Default() CodeExecutionToolResultError {
138	return "code_execution_tool_result_error"
139}
140func (c Completion) Default() Completion                     { return "completion" }
141func (c Computer) Default() Computer                         { return "computer" }
142func (c Computer20241022) Default() Computer20241022         { return "computer_20241022" }
143func (c Computer20250124) Default() Computer20250124         { return "computer_20250124" }
144func (c ContainerUpload) Default() ContainerUpload           { return "container_upload" }
145func (c Content) Default() Content                           { return "content" }
146func (c ContentBlockDelta) Default() ContentBlockDelta       { return "content_block_delta" }
147func (c ContentBlockLocation) Default() ContentBlockLocation { return "content_block_location" }
148func (c ContentBlockStart) Default() ContentBlockStart       { return "content_block_start" }
149func (c ContentBlockStop) Default() ContentBlockStop         { return "content_block_stop" }
150func (c Disabled) Default() Disabled                         { return "disabled" }
151func (c Document) Default() Document                         { return "document" }
152func (c Enabled) Default() Enabled                           { return "enabled" }
153func (c Ephemeral) Default() Ephemeral                       { return "ephemeral" }
154func (c Error) Default() Error                               { return "error" }
155func (c Errored) Default() Errored                           { return "errored" }
156func (c Expired) Default() Expired                           { return "expired" }
157func (c File) Default() File                                 { return "file" }
158func (c Image) Default() Image                               { return "image" }
159func (c InputJSONDelta) Default() InputJSONDelta             { return "input_json_delta" }
160func (c InvalidRequestError) Default() InvalidRequestError   { return "invalid_request_error" }
161func (c MCPToolResult) Default() MCPToolResult               { return "mcp_tool_result" }
162func (c MCPToolUse) Default() MCPToolUse                     { return "mcp_tool_use" }
163func (c Message) Default() Message                           { return "message" }
164func (c MessageBatch) Default() MessageBatch                 { return "message_batch" }
165func (c MessageBatchDeleted) Default() MessageBatchDeleted   { return "message_batch_deleted" }
166func (c MessageDelta) Default() MessageDelta                 { return "message_delta" }
167func (c MessageStart) Default() MessageStart                 { return "message_start" }
168func (c MessageStop) Default() MessageStop                   { return "message_stop" }
169func (c Model) Default() Model                               { return "model" }
170func (c None) Default() None                                 { return "none" }
171func (c NotFoundError) Default() NotFoundError               { return "not_found_error" }
172func (c Object) Default() Object                             { return "object" }
173func (c OverloadedError) Default() OverloadedError           { return "overloaded_error" }
174func (c PageLocation) Default() PageLocation                 { return "page_location" }
175func (c PermissionError) Default() PermissionError           { return "permission_error" }
176func (c RateLimitError) Default() RateLimitError             { return "rate_limit_error" }
177func (c RedactedThinking) Default() RedactedThinking         { return "redacted_thinking" }
178func (c ServerToolUse) Default() ServerToolUse               { return "server_tool_use" }
179func (c SignatureDelta) Default() SignatureDelta             { return "signature_delta" }
180func (c StrReplaceBasedEditTool) Default() StrReplaceBasedEditTool {
181	return "str_replace_based_edit_tool"
182}
183func (c StrReplaceEditor) Default() StrReplaceEditor     { return "str_replace_editor" }
184func (c Succeeded) Default() Succeeded                   { return "succeeded" }
185func (c Text) Default() Text                             { return "text" }
186func (c TextDelta) Default() TextDelta                   { return "text_delta" }
187func (c TextEditor20241022) Default() TextEditor20241022 { return "text_editor_20241022" }
188func (c TextEditor20250124) Default() TextEditor20250124 { return "text_editor_20250124" }
189func (c TextEditor20250429) Default() TextEditor20250429 { return "text_editor_20250429" }
190func (c TextPlain) Default() TextPlain                   { return "text/plain" }
191func (c Thinking) Default() Thinking                     { return "thinking" }
192func (c ThinkingDelta) Default() ThinkingDelta           { return "thinking_delta" }
193func (c TimeoutError) Default() TimeoutError             { return "timeout_error" }
194func (c Tool) Default() Tool                             { return "tool" }
195func (c ToolResult) Default() ToolResult                 { return "tool_result" }
196func (c ToolUse) Default() ToolUse                       { return "tool_use" }
197func (c URL) Default() URL                               { return "url" }
198func (c WebSearch) Default() WebSearch                   { return "web_search" }
199func (c WebSearch20250305) Default() WebSearch20250305   { return "web_search_20250305" }
200func (c WebSearchResult) Default() WebSearchResult       { return "web_search_result" }
201func (c WebSearchResultLocation) Default() WebSearchResultLocation {
202	return "web_search_result_location"
203}
204func (c WebSearchToolResult) Default() WebSearchToolResult { return "web_search_tool_result" }
205func (c WebSearchToolResultError) Default() WebSearchToolResultError {
206	return "web_search_tool_result_error"
207}
208
209func (c Any) MarshalJSON() ([]byte, error)                          { return marshalString(c) }
210func (c APIError) MarshalJSON() ([]byte, error)                     { return marshalString(c) }
211func (c ApplicationPDF) MarshalJSON() ([]byte, error)               { return marshalString(c) }
212func (c Approximate) MarshalJSON() ([]byte, error)                  { return marshalString(c) }
213func (c Assistant) MarshalJSON() ([]byte, error)                    { return marshalString(c) }
214func (c AuthenticationError) MarshalJSON() ([]byte, error)          { return marshalString(c) }
215func (c Auto) MarshalJSON() ([]byte, error)                         { return marshalString(c) }
216func (c Base64) MarshalJSON() ([]byte, error)                       { return marshalString(c) }
217func (c Bash) MarshalJSON() ([]byte, error)                         { return marshalString(c) }
218func (c Bash20241022) MarshalJSON() ([]byte, error)                 { return marshalString(c) }
219func (c Bash20250124) MarshalJSON() ([]byte, error)                 { return marshalString(c) }
220func (c BillingError) MarshalJSON() ([]byte, error)                 { return marshalString(c) }
221func (c Canceled) MarshalJSON() ([]byte, error)                     { return marshalString(c) }
222func (c CharLocation) MarshalJSON() ([]byte, error)                 { return marshalString(c) }
223func (c CitationsDelta) MarshalJSON() ([]byte, error)               { return marshalString(c) }
224func (c CodeExecution) MarshalJSON() ([]byte, error)                { return marshalString(c) }
225func (c CodeExecution20250522) MarshalJSON() ([]byte, error)        { return marshalString(c) }
226func (c CodeExecutionOutput) MarshalJSON() ([]byte, error)          { return marshalString(c) }
227func (c CodeExecutionResult) MarshalJSON() ([]byte, error)          { return marshalString(c) }
228func (c CodeExecutionToolResult) MarshalJSON() ([]byte, error)      { return marshalString(c) }
229func (c CodeExecutionToolResultError) MarshalJSON() ([]byte, error) { return marshalString(c) }
230func (c Completion) MarshalJSON() ([]byte, error)                   { return marshalString(c) }
231func (c Computer) MarshalJSON() ([]byte, error)                     { return marshalString(c) }
232func (c Computer20241022) MarshalJSON() ([]byte, error)             { return marshalString(c) }
233func (c Computer20250124) MarshalJSON() ([]byte, error)             { return marshalString(c) }
234func (c ContainerUpload) MarshalJSON() ([]byte, error)              { return marshalString(c) }
235func (c Content) MarshalJSON() ([]byte, error)                      { return marshalString(c) }
236func (c ContentBlockDelta) MarshalJSON() ([]byte, error)            { return marshalString(c) }
237func (c ContentBlockLocation) MarshalJSON() ([]byte, error)         { return marshalString(c) }
238func (c ContentBlockStart) MarshalJSON() ([]byte, error)            { return marshalString(c) }
239func (c ContentBlockStop) MarshalJSON() ([]byte, error)             { return marshalString(c) }
240func (c Disabled) MarshalJSON() ([]byte, error)                     { return marshalString(c) }
241func (c Document) MarshalJSON() ([]byte, error)                     { return marshalString(c) }
242func (c Enabled) MarshalJSON() ([]byte, error)                      { return marshalString(c) }
243func (c Ephemeral) MarshalJSON() ([]byte, error)                    { return marshalString(c) }
244func (c Error) MarshalJSON() ([]byte, error)                        { return marshalString(c) }
245func (c Errored) MarshalJSON() ([]byte, error)                      { return marshalString(c) }
246func (c Expired) MarshalJSON() ([]byte, error)                      { return marshalString(c) }
247func (c File) MarshalJSON() ([]byte, error)                         { return marshalString(c) }
248func (c Image) MarshalJSON() ([]byte, error)                        { return marshalString(c) }
249func (c InputJSONDelta) MarshalJSON() ([]byte, error)               { return marshalString(c) }
250func (c InvalidRequestError) MarshalJSON() ([]byte, error)          { return marshalString(c) }
251func (c MCPToolResult) MarshalJSON() ([]byte, error)                { return marshalString(c) }
252func (c MCPToolUse) MarshalJSON() ([]byte, error)                   { return marshalString(c) }
253func (c Message) MarshalJSON() ([]byte, error)                      { return marshalString(c) }
254func (c MessageBatch) MarshalJSON() ([]byte, error)                 { return marshalString(c) }
255func (c MessageBatchDeleted) MarshalJSON() ([]byte, error)          { return marshalString(c) }
256func (c MessageDelta) MarshalJSON() ([]byte, error)                 { return marshalString(c) }
257func (c MessageStart) MarshalJSON() ([]byte, error)                 { return marshalString(c) }
258func (c MessageStop) MarshalJSON() ([]byte, error)                  { return marshalString(c) }
259func (c Model) MarshalJSON() ([]byte, error)                        { return marshalString(c) }
260func (c None) MarshalJSON() ([]byte, error)                         { return marshalString(c) }
261func (c NotFoundError) MarshalJSON() ([]byte, error)                { return marshalString(c) }
262func (c Object) MarshalJSON() ([]byte, error)                       { return marshalString(c) }
263func (c OverloadedError) MarshalJSON() ([]byte, error)              { return marshalString(c) }
264func (c PageLocation) MarshalJSON() ([]byte, error)                 { return marshalString(c) }
265func (c PermissionError) MarshalJSON() ([]byte, error)              { return marshalString(c) }
266func (c RateLimitError) MarshalJSON() ([]byte, error)               { return marshalString(c) }
267func (c RedactedThinking) MarshalJSON() ([]byte, error)             { return marshalString(c) }
268func (c ServerToolUse) MarshalJSON() ([]byte, error)                { return marshalString(c) }
269func (c SignatureDelta) MarshalJSON() ([]byte, error)               { return marshalString(c) }
270func (c StrReplaceBasedEditTool) MarshalJSON() ([]byte, error)      { return marshalString(c) }
271func (c StrReplaceEditor) MarshalJSON() ([]byte, error)             { return marshalString(c) }
272func (c Succeeded) MarshalJSON() ([]byte, error)                    { return marshalString(c) }
273func (c Text) MarshalJSON() ([]byte, error)                         { return marshalString(c) }
274func (c TextDelta) MarshalJSON() ([]byte, error)                    { return marshalString(c) }
275func (c TextEditor20241022) MarshalJSON() ([]byte, error)           { return marshalString(c) }
276func (c TextEditor20250124) MarshalJSON() ([]byte, error)           { return marshalString(c) }
277func (c TextEditor20250429) MarshalJSON() ([]byte, error)           { return marshalString(c) }
278func (c TextPlain) MarshalJSON() ([]byte, error)                    { return marshalString(c) }
279func (c Thinking) MarshalJSON() ([]byte, error)                     { return marshalString(c) }
280func (c ThinkingDelta) MarshalJSON() ([]byte, error)                { return marshalString(c) }
281func (c TimeoutError) MarshalJSON() ([]byte, error)                 { return marshalString(c) }
282func (c Tool) MarshalJSON() ([]byte, error)                         { return marshalString(c) }
283func (c ToolResult) MarshalJSON() ([]byte, error)                   { return marshalString(c) }
284func (c ToolUse) MarshalJSON() ([]byte, error)                      { return marshalString(c) }
285func (c URL) MarshalJSON() ([]byte, error)                          { return marshalString(c) }
286func (c WebSearch) MarshalJSON() ([]byte, error)                    { return marshalString(c) }
287func (c WebSearch20250305) MarshalJSON() ([]byte, error)            { return marshalString(c) }
288func (c WebSearchResult) MarshalJSON() ([]byte, error)              { return marshalString(c) }
289func (c WebSearchResultLocation) MarshalJSON() ([]byte, error)      { return marshalString(c) }
290func (c WebSearchToolResult) MarshalJSON() ([]byte, error)          { return marshalString(c) }
291func (c WebSearchToolResultError) MarshalJSON() ([]byte, error)     { return marshalString(c) }
292
293type constant[T any] interface {
294	Constant[T]
295	*T
296}
297
298func marshalString[T ~string, PT constant[T]](v T) ([]byte, error) {
299	var zero T
300	if v == zero {
301		v = PT(&v).Default()
302	}
303	return json.Marshal(string(v))
304}