sdk

package module
v1.35.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Aug 5, 2026 License: Apache-2.0 Imports: 16 Imported by: 7

README

🚀 Inference Gateway Go SDK

A powerful and easy-to-use Go SDK for the Inference Gateway

Go Reference Release Go Version

Connect to multiple LLM providers through a unified interface • Stream responses • Function calling • Vision support • MCP tools support • Middleware control

InstallationQuick StartExamplesDocumentation


Installation

To install the SDK, use go get:

go get github.com/inference-gateway/sdk

Usage

Creating a Client

To create a client, use the NewClient function:

package main

import (
    "fmt"
    "log"

    sdk "github.com/inference-gateway/sdk"
)

func main() {
    client := sdk.NewClient(&sdk.ClientOptions{
        BaseURL: "http://localhost:8080/v1",
    })
}
Using Custom Headers

The SDK supports custom HTTP headers that can be included with all requests. You can set headers in three ways:

  1. Initial headers via ClientOptions:
client := sdk.NewClient(&sdk.ClientOptions{
    BaseURL: "http://localhost:8080/v1",
    Headers: map[string]string{
        "X-Custom-Header": "my-value",
        "User-Agent":      "my-app/1.0",
    },
})
  1. Multiple headers using WithHeaders:
client = client.WithHeaders(map[string]string{
    "X-Request-ID": "abc123",
    "X-Source":     "sdk",
})
  1. Single header using WithHeader:
client = client.WithHeader("Authorization", "Bearer token123")

Headers can be combined and will override previous values if the same header name is used:

client := sdk.NewClient(&sdk.ClientOptions{
    BaseURL: "http://localhost:8080/v1",
    Headers: map[string]string{
        "X-App-Name": "my-app",
    },
})

// Add more headers
client = client.WithHeaders(map[string]string{
    "X-Request-ID": "req-123",
    "X-Version":    "1.0",
}).WithHeader("Authorization", "Bearer token")

// All subsequent requests will include all these headers
response, err := client.GenerateContent(ctx, provider, model, messages)
Retry Mechanism

The SDK includes a built-in retry mechanism for handling transient failures and network issues. By default, the client will automatically retry requests that fail with retryable status codes.

Default Retry Configuration:

client := sdk.NewClient(&sdk.ClientOptions{
    BaseURL: "http://localhost:8080/v1",
    // Default retry configuration is automatically applied
})

The default configuration includes:

  • Max Retries: 3 attempts
  • Timeout: 30 seconds per request
  • Backoff Strategy: Exponential backoff with jitter
  • Retryable Status Codes: 429 (Too Many Requests), 500 (Internal Server Error), 502 (Bad Gateway), 503 (Service Unavailable), 504 (Gateway Timeout)

Custom Retry Configuration:

You can customize the retry behavior by providing your own retry options:

client := sdk.NewClient(&sdk.ClientOptions{
    BaseURL: "http://localhost:8080/v1",
    RetryOptions: &sdk.RetryOptions{
        MaxRetries:    5,                            // Maximum number of retry attempts
        Timeout:       time.Duration(60) * time.Second, // Timeout per request
        MinDelay:      time.Duration(1) * time.Second,  // Minimum delay between retries
        MaxDelay:      time.Duration(30) * time.Second, // Maximum delay between retries
        RetryableStatusCodes: []int{429, 500, 502, 503, 504}, // HTTP status codes to retry
    },
})

Exponential Backoff with Jitter:

The retry mechanism uses exponential backoff with jitter to prevent thundering herd problems. The delay between retries is calculated as:

  1. Base delay starts at MinDelay and doubles with each retry
  2. Capped at MaxDelay to prevent excessive waiting
  3. Random jitter (±25%) is added to spread out retry attempts

Example delay sequence (with 1s MinDelay, 30s MaxDelay):

  • 1st retry: ~1s (0.75s - 1.25s with jitter)
  • 2nd retry: ~2s (1.5s - 2.5s with jitter)
  • 3rd retry: ~4s (3s - 5s with jitter)
  • 4th retry: ~8s (6s - 10s with jitter)
  • 5th retry: ~16s (12s - 20s with jitter)

Disabling Retries:

To disable automatic retries, set MaxRetries to 0:

client := sdk.NewClient(&sdk.ClientOptions{
    BaseURL: "http://localhost:8080/v1",
    RetryOptions: &sdk.RetryOptions{
        MaxRetries: 0, // Disables retries
    },
})

Rate Limiting (429 Status):

When the server returns a 429 (Too Many Requests) status code, the SDK will:

  1. Check for a Retry-After header
  2. If present, wait for the specified duration before retrying
  3. If not present, use the standard exponential backoff strategy

Context and Cancellation:

Retries respect the context passed to API methods. If the context is cancelled or times out, retries will stop immediately:

ctx, cancel := context.WithTimeout(context.Background(), 2*time.Minute)
defer cancel()

// Retries will stop if the context times out
response, err := client.GenerateContent(ctx, provider, model, messages)
Middleware Options

The Inference Gateway supports various middleware layers (MCP tools) that can be bypassed for direct provider access. The SDK provides WithMiddlewareOptions to control middleware behavior:

package main

import (
    "context"
    "fmt"
    "log"

    sdk "github.com/inference-gateway/sdk"
)

func main() {
    client := sdk.NewClient(&sdk.ClientOptions{
        BaseURL: "http://localhost:8080/v1",
        APIKey:  "your-api-key",
    })

    ctx := context.Background()
    messages := []sdk.Message{
        {Role: sdk.User, Content: sdk.NewMessageContent("Hello, world!")},
    }

    // 1. Skip MCP middleware only
    response1, err := client.WithMiddlewareOptions(&sdk.MiddlewareOptions{
        SkipMCP: true,
    }).GenerateContent(ctx, sdk.Openai, "gpt-4o", messages)

    // 2. Direct provider access (bypasses all middleware)
    response3, err := client.WithMiddlewareOptions(&sdk.MiddlewareOptions{
        DirectProvider: true,
    }).GenerateContent(ctx, sdk.Openai, "gpt-4o", messages)

    // 3. Skip MCP middleware
    response4, err := client.WithMiddlewareOptions(&sdk.MiddlewareOptions{
        SkipMCP: true,
    }).GenerateContent(ctx, sdk.Openai, "gpt-4o", messages)
}

Middleware Options:

  • SkipMCP - Bypasses MCP (Model Context Protocol) middleware processing
  • DirectProvider - Routes directly to the provider without any middleware

Method Chaining:

Middleware options can be chained with other configuration methods:

response, err := client.
    WithHeader("X-Custom-Header", "value").
    WithMiddlewareOptions(&sdk.MiddlewareOptions{
        SkipMCP: true,
    }).
    GenerateContent(ctx, sdk.Openai, "gpt-4o", messages)

Alternative Header Approach:

You can also control middleware using custom headers directly:

response, err := client.
    WithHeader("X-MCP-Bypass", "true").
    WithHeader("X-Direct-Provider", "true").
    GenerateContent(ctx, sdk.Openai, "gpt-4o", messages)

Note: Middleware options apply to all subsequent API calls until overridden with a new WithMiddlewareOptions call. The gateway must support the corresponding headers for this functionality to work properly.

Listing Models

To list available models, use the ListModels method:

client := sdk.NewClient(&sdk.ClientOptions{
    BaseURL: "http://localhost:8080/v1",
})

ctx := context.Background()

// List all models from all providers
resp, err := client.ListModels(ctx)
if err != nil {
    log.Fatalf("Error listing models: %v", err)
}
fmt.Printf("All available models: %+v\n", resp.Data)

// List models for a specific provider
groqResp, err := client.ListProviderModels(ctx, sdk.Groq)
if err != nil {
    log.Fatalf("Error listing provider models: %v", err)
}
fmt.Printf("Provider: %s\n", *groqResp.Provider)
fmt.Printf("Available Groq models: %+v\n", groqResp.Data)

// Request additional per-model metadata (?include=context_window)
withCtx, err := client.ListModels(ctx, sdk.ContextWindow)
if err != nil {
    log.Fatalf("Error listing models: %v", err)
}
for _, model := range withCtx.Data {
    if model.ContextWindow != nil {
        fmt.Printf("%s context window: %d tokens\n", model.ID, *model.ContextWindow)
    }
}
Listing MCP Tools

To list available MCP (Model Context Protocol) tools, use the ListTools method. This functionality is only available when EXPOSE_MCP=true is set on the Inference Gateway server:

client := sdk.NewClient(&sdk.ClientOptions{
    BaseURL: "http://localhost:8080/v1",
    APIKey:  "your-api-key", // Required for MCP tools access
})

ctx := context.Background()
tools, err := client.ListTools(ctx)
if err != nil {
    log.Fatalf("Error listing tools: %v", err)
}

fmt.Printf("Found %d MCP tools:\n", len(tools.Data))
for _, tool := range tools.Data {
    fmt.Printf("- %s: %s (Server: %s)\n", tool.Name, tool.Description, tool.Server)
    if tool.InputSchema != nil {
        fmt.Printf("  Input Schema: %+v\n", *tool.InputSchema)
    }
}

Note: The MCP tools endpoint requires authentication and is only accessible when the server has EXPOSE_MCP=true configured. If the endpoint is not exposed, you'll receive a 403 error with the message "MCP tools endpoint is not exposed. Set EXPOSE_MCP=true to enable."

Generating Content

To generate content using a model, use the GenerateContent method:

Note: Some models support reasoning capabilities. You can use the ReasoningFormat parameter to control how reasoning is provided in the response. The model's reasoning will be available in the Reasoning or ReasoningContent fields of the response message.

client := sdk.NewClient(&sdk.ClientOptions{
    BaseURL: "http://localhost:8080/v1",
})

ctx := context.Background()
response, err := client.GenerateContent(
    ctx,
    sdk.Ollama,
    "ollama/llama2",
    []sdk.Message{
        {
            Role:    sdk.System,
            Content: sdk.NewMessageContent("You are a helpful assistant."),
        },
        {
            Role:    sdk.User,
            Content: sdk.NewMessageContent("What is Go?"),
        },
    },
)
if err != nil {
    log.Printf("Error generating content: %v", err)
    return
}

var chatCompletion CreateChatCompletionResponse
if err := json.Unmarshal(response.RawResponse, &chatCompletion); err != nil {
    log.Printf("Error unmarshaling response: %v", err)
    return
}

fmt.Printf("Generated content: %s\n", chatCompletion.Choices[0].Message.Content)

// If reasoning was requested and the model supports it
if chatCompletion.Choices[0].Message.Reasoning != nil {
    fmt.Printf("Reasoning: %s\n", *chatCompletion.Choices[0].Message.Reasoning)
}
Vision Support

The SDK supports multimodal messages with images for vision-capable models like GPT-4 Vision. You can include images via URLs or base64-encoded data.

Simple Text Message (Backward Compatible)
// Create a simple text message
textMessage, err := sdk.NewTextMessage(sdk.User, "What is Go programming language?")
if err != nil {
    log.Fatal(err)
}

response, err := client.GenerateContent(
    context.Background(),
    sdk.Openai,
    "gpt-4o",
    []sdk.Message{textMessage},
)
Vision Message with Image URL
// Create content parts with text and image
var contentParts []sdk.ContentPart

// Add text part
textPart, err := sdk.NewTextContentPart("What is in this image?")
if err != nil {
    log.Fatal(err)
}
contentParts = append(contentParts, textPart)

// Add image part (auto detail level by default)
imagePart, err := sdk.NewImageContentPart(
    "https://example.com/image.jpg",
    nil, // detail level: nil for auto, or &sdk.High, &sdk.Low
)
if err != nil {
    log.Fatal(err)
}
contentParts = append(contentParts, imagePart)

// Create vision message
visionMessage, err := sdk.NewImageMessage(sdk.User, contentParts)
if err != nil {
    log.Fatal(err)
}

response, err := client.GenerateContent(
    context.Background(),
    sdk.Openai,
    "gpt-4o",
    []sdk.Message{visionMessage},
)
Vision Message with Base64 Encoded Image
// Use high detail level for better image analysis
highDetail := sdk.High
imagePart, err := sdk.NewImageContentPart(
    "data:image/jpeg;base64,/9j/4AAQSkZJRgABAQEAYABgAAD...",
    &highDetail,
)
if err != nil {
    log.Fatal(err)
}
Multiple Images in One Message
var contentParts []sdk.ContentPart

// Add text
textPart, _ := sdk.NewTextContentPart("Compare these images:")
contentParts = append(contentParts, textPart)

// Add first image
image1, _ := sdk.NewImageContentPart("https://example.com/image1.jpg", nil)
contentParts = append(contentParts, image1)

// Add second image
image2, _ := sdk.NewImageContentPart("https://example.com/image2.jpg", nil)
contentParts = append(contentParts, image2)

visionMessage, _ := sdk.NewImageMessage(sdk.User, contentParts)

Image Detail Levels:

  • nil or &sdk.Auto: Automatic detail level (default)
  • &sdk.Low: Lower resolution, faster and cheaper
  • &sdk.High: Higher resolution, better quality but more expensive

For a complete example, see examples/vision/main.go.

Using ReasoningFormat

You can enable reasoning capabilities by setting the ReasoningFormat parameter in your request:

client := sdk.NewClient(&sdk.ClientOptions{
    BaseURL: "http://localhost:8080/v1",
})

ctx := context.Background()

// Set up your messages
messages := []sdk.Message{
    {
        Role:    sdk.System,
        Content: sdk.NewMessageContent("You are a helpful assistant. Please include your reasoning for complex questions."),
    },
    {
        Role:    sdk.User,
        Content: sdk.NewMessageContent("What is the square root of 144 and why?"),
    },
}

// Create a request with reasoning format
reasoningFormat := "parsed"  // Use "raw" or "parsed" - default to "parsed" if not specified
options := &sdk.CreateChatCompletionRequest{
    ReasoningFormat: &reasoningFormat,
}

// Set options and make the request
response, err := client.WithOptions(options).GenerateContent(
    ctx,
    sdk.Anthropic,
    "anthropic/claude-3-opus-20240229",
    messages,
)

if err != nil {
    log.Fatalf("Error generating content: %v", err)
}

fmt.Printf("Content: %s\n", response.Choices[0].Message.Content)
if response.Choices[0].Message.Reasoning != nil {
    fmt.Printf("Reasoning: %s\n", *response.Choices[0].Message.Reasoning)
}
Streaming Content

To generate content using streaming mode, use the GenerateContentStream method:

client := sdk.NewClient(&sdk.ClientOptions{
    BaseURL: "http://localhost:8080/v1",
})
ctx := context.Background()
events, err := client.GenerateContentStream(
    ctx,
    sdk.Ollama,
    "ollama/llama2",
    []sdk.Message{
        {
            Role:    sdk.System,
            Content: sdk.NewMessageContent("You are a helpful assistant."),
        },
        {
            Role:    sdk.User,
            Content: sdk.NewMessageContent("What is Go?"),
        },
    },
)
if err != nil {
    log.Fatalf("Error generating content stream: %v", err)
}

// Read events from the stream / channel
for event := range events {
    if event.Event != nil {
        continue
    }

    switch *event.Event {
    case sdk.ContentDelta:
        if event.Data != nil {
            // Parse the streaming response
            var streamResponse sdk.CreateChatCompletionStreamResponse
            if err := json.Unmarshal(*event.Data, &streamResponse); err != nil {
                log.Printf("Error parsing stream response: %v", err)
                continue
            }

            // Process each choice in the response
            for _, choice := range streamResponse.Choices {
                // Handle reasoning content (both reasoning and reasoning_content fields)
                if choice.Delta.Reasoning != nil && *choice.Delta.Reasoning != "" {
                    fmt.Printf("💭 Reasoning: %s\n", *choice.Delta.Reasoning)
                }
                if choice.Delta.ReasoningContent != nil && *choice.Delta.ReasoningContent != "" {
                    fmt.Printf("💭 Reasoning: %s\n", *choice.Delta.ReasoningContent)
                }
                
                if choice.Delta.Content != "" {
                    // Just print the content as it comes in
                    fmt.Print(choice.Delta.Content)
                }
            }
        }

    case sdk.StreamEnd:
        // Stream has ended
        fmt.Println("\nStream ended")

    case sdk.MessageError:
        // Handle error events
        if event.Data != nil {
            var errResp struct {
                Error string `json:"error"`
            }
            if err := json.Unmarshal(*event.Data, &errResp); err != nil {
                log.Printf("Error parsing error: %v", err)
                continue
            }
            log.Printf("Error: %s", errResp.Error)
        }
    }
}
Messages API (Anthropic-compatible)

The gateway also exposes an Anthropic-compatible Messages API (POST /messages). Not every provider implements it - unsupported providers return an error, so use GenerateContent for those.

client := sdk.NewClient(&sdk.ClientOptions{
    BaseURL: "http://localhost:8080/v1",
})
ctx := context.Background()

var content sdk.MessagesMessage_Content
if err := content.FromMessagesMessageContent0("What is Go?"); err != nil {
    log.Fatalf("Failed to build content: %v", err)
}

response, err := client.CreateMessage(ctx, sdk.Anthropic, sdk.CreateMessagesRequest{
    Model:     "claude-sonnet-5",
    MaxTokens: 1024,
    Messages: []sdk.MessagesMessage{
        {Role: sdk.MessagesMessageRoleUser, Content: content},
    },
})
if err != nil {
    log.Fatalf("Failed to create message: %v", err)
}

for _, block := range response.Content {
    if text, err := block.AsMessagesTextBlock(); err == nil {
        fmt.Println(text.Text)
    }
}

For streaming, use CreateMessageStream. Each ContentDelta event's Data is a JSON-serialized sdk.MessagesStreamEvent - switch on its Type field (message_start, content_block_delta, message_stop, ...) or just read Delta.Text:

events, err := client.CreateMessageStream(ctx, sdk.Anthropic, request)
if err != nil {
    log.Fatalf("Failed to create message stream: %v", err)
}

for event := range events {
    if event.Event == nil {
        continue
    }
    switch *event.Event {
    case sdk.ContentDelta:
        var streamEvent sdk.MessagesStreamEvent
        if err := json.Unmarshal(*event.Data, &streamEvent); err != nil {
            continue
        }
        if streamEvent.Delta != nil && streamEvent.Delta.Text != nil {
            fmt.Print(*streamEvent.Delta.Text)
        }
    case sdk.StreamEnd:
        fmt.Println("\nStream ended")
    }
}

For a complete example, see examples/messages/main.go.

Tool-Use

To use tools with the SDK, you can define a tool and provide it to the client:

client := sdk.NewClient(&sdk.ClientOptions{
    BaseURL: "http://localhost:8080/v1",
})

// Create tools array with our function
tools := []sdk.ChatCompletionTool{
    {
        Type:     sdk.Function,
        Function: sdk.FunctionObject{
            Name:        "get_current_weather",
            Description: new("Get the current weather in a given location"),
            Parameters: &sdk.FunctionParameters{
                "type": "object",
                "properties": map[string]any{
                    "location": map[string]any{
                        "type":        "string",
                        "enum":        []string{"san francisco", "new york", "london", "tokyo", "sydney"},
                        "description": "The city and state, e.g. San Francisco, CA",
                    },
                    "unit": map[string]any{
                        "type":        "string",
                        "enum":        []string{"celsius", "fahrenheit"},
                        "description": "The temperature unit to use",
                    },
                },
                "required": []string{"location"},
            },
        }
    },
    {
        Type:     sdk.Function,
        Function: sdk.FunctionObject{
            Name:        "get_current_time",
            Description: new("Get the current time in a given location"),
            Parameters: &sdk.FunctionParameters{
                "type": "object",
                "properties": map[string]any{
                    "location": map[string]any{
                        "type":        "string",
                        "enum":        []string{"san francisco", "new york", "london", "tokyo", "sydney"},
                        "description": "The city and state, e.g. San Francisco, CA",
                    },
                },
                "required": []string{"location"},
            },
        }
    }
}

// Provide the tool to the client
client.WithTools(&tools).GenerateContent(ctx, provider, modelName, messages)
Health Check

To check if the API is healthy:

client := sdk.NewClient(&sdk.ClientOptions{
    BaseURL: "http://localhost:8080/v1",
})

ctx := context.Background()
err := client.HealthCheck(ctx)
if err != nil {
    log.Fatalf("Health check failed: %v", err)
}

Examples

For more detailed examples and use cases, check out the examples directory. The examples include:

Each example includes its own README with specific instructions and explanations.

Supported Providers

The SDK supports the following LLM providers:

  • Ollama (sdk.Ollama)
  • Ollama Cloud (sdk.OllamaCloud)
  • Groq (sdk.Groq)
  • OpenAI (sdk.Openai)
  • DeepSeek (sdk.Deepseek)
  • Cloudflare (sdk.Cloudflare)
  • Cohere (sdk.Cohere)
  • Anthropic (sdk.Anthropic)
  • Google (sdk.Google)
  • Mistral AI (sdk.Mistral)
  • MiniMax (sdk.Minimax)
  • Moonshot (sdk.Moonshot)

Documentation

  1. Run: task docs
  2. Open: http://localhost:6060/pkg/github.com/inference-gateway/sdk

Contributing

Please refer to the CONTRIBUTING.md file for information about how to get involved. We welcome issues, questions, and pull requests.

License

This SDK is distributed under the Apache 2.0 License, see LICENSE for more information.

Documentation

Overview

Package sdk provides primitives to interact with the openapi HTTP API.

Code generated by github.com/oapi-codegen/oapi-codegen/v2 version v2.8.0 DO NOT EDIT.

Index

Constants

Backwards-compatible aliases for enum values renamed by the schemas v0.11.1 generated-code sync.

Variables

This section is empty.

Functions

This section is empty.

Types

type BadRequest added in v1.5.0

type BadRequest = Error

BadRequest defines model for BadRequest.

type CacheControl added in v1.26.0

type CacheControl struct {
	// Type The cache control type. Currently only `ephemeral`.
	Type CacheControlType `json:"type"`
}

CacheControl Cache control settings for prompt caching. Currently only `ephemeral` caching is supported.

type CacheControlType added in v1.26.0

type CacheControlType string

CacheControlType The cache control type. Currently only `ephemeral`.

const (
	Ephemeral CacheControlType = "ephemeral"
)

Defines values for CacheControlType.

func (CacheControlType) Valid added in v1.26.0

func (e CacheControlType) Valid() bool

Valid indicates whether the value is a known member of the CacheControlType enum.

type ChatCompletionChoice added in v1.5.0

type ChatCompletionChoice struct {
	// FinishReason The reason the model stopped generating tokens. This will be `stop` if the model hit a natural stop point or a provided stop sequence,
	// `length` if the maximum number of tokens specified in the request was reached,
	// `content_filter` if content was omitted due to a flag from our content filters,
	// `tool_calls` if the model called a tool.
	FinishReason FinishReason `json:"finish_reason"`

	// Index The index of the choice in the list of choices.
	Index int `json:"index"`

	// Logprobs Log probability information for the choice.
	Logprobs *struct {
		// Content A list of message content tokens with log probability information.
		Content []ChatCompletionTokenLogprob `json:"content"`

		// Refusal A list of message refusal tokens with log probability information.
		Refusal []ChatCompletionTokenLogprob `json:"refusal"`
	} `json:"logprobs,omitempty"`

	// Message Message structure for provider requests
	Message Message `json:"message"`
}

ChatCompletionChoice defines model for ChatCompletionChoice.

type ChatCompletionMessageToolCall added in v1.5.0

type ChatCompletionMessageToolCall struct {
	// ExtraContent Provider-specific opaque data attached to a tool call. The contents are
	// not interpreted by the gateway, but must be echoed back verbatim on the
	// next request that references this tool call. Currently used by Google
	// Gemini extended-thinking models to carry the per-call `thought_signature`.
	// Other providers may ignore the field.
	ExtraContent *ToolCallExtraContent `json:"extra_content,omitempty"`

	// Function The function that the model called.
	Function ChatCompletionMessageToolCallFunction `json:"function"`

	// ID The ID of the tool call.
	ID string `json:"id"`

	// Type The type of the tool. Currently, only `function` is supported.
	Type ChatCompletionToolType `json:"type"`
}

ChatCompletionMessageToolCall defines model for ChatCompletionMessageToolCall.

type ChatCompletionMessageToolCallChunk added in v1.5.0

type ChatCompletionMessageToolCallChunk struct {
	// ExtraContent Provider-specific opaque data attached to a tool call. The contents are
	// not interpreted by the gateway, but must be echoed back verbatim on the
	// next request that references this tool call. Currently used by Google
	// Gemini extended-thinking models to carry the per-call `thought_signature`.
	// Other providers may ignore the field.
	ExtraContent *ToolCallExtraContent `json:"extra_content,omitempty"`

	// Function The function that the model called.
	Function *ChatCompletionMessageToolCallFunction `json:"function,omitempty"`

	// ID The ID of the tool call.
	ID    *string `json:"id,omitempty"`
	Index int     `json:"index"`

	// Type The type of the tool. Currently, only `function` is supported.
	Type *string `json:"type,omitempty"`
}

ChatCompletionMessageToolCallChunk defines model for ChatCompletionMessageToolCallChunk.

type ChatCompletionMessageToolCallFunction added in v1.5.0

type ChatCompletionMessageToolCallFunction struct {
	// Arguments The arguments to call the function with, as generated by the model in JSON format. Note that the model does not always generate valid JSON, and may hallucinate parameters not defined by your function schema. Validate the arguments in your code before calling your function.
	Arguments string `json:"arguments"`

	// Name The name of the function to call.
	Name string `json:"name"`
}

ChatCompletionMessageToolCallFunction The function that the model called.

type ChatCompletionNamedToolChoice added in v1.18.0

type ChatCompletionNamedToolChoice struct {
	Function struct {
		// Name The name of the function to call.
		Name string `json:"name"`
	} `json:"function"`

	// Type The type of the tool. Currently, only `function` is supported.
	Type ChatCompletionToolType `json:"type"`
}

ChatCompletionNamedToolChoice Specifies a tool the model should use. Use to force the model to call a specific function.

type ChatCompletionStreamChoice added in v1.5.0

type ChatCompletionStreamChoice struct {
	// Delta A chat completion delta generated by streamed model responses.
	Delta ChatCompletionStreamResponseDelta `json:"delta"`

	// FinishReason The reason the model stopped generating tokens. This will be `stop` if the model hit a natural stop point or a provided stop sequence,
	// `length` if the maximum number of tokens specified in the request was reached,
	// `content_filter` if content was omitted due to a flag from our content filters,
	// `tool_calls` if the model called a tool.
	FinishReason FinishReason `json:"finish_reason"`

	// Index The index of the choice in the list of choices.
	Index int `json:"index"`

	// Logprobs Log probability information for the choice.
	Logprobs *struct {
		// Content A list of message content tokens with log probability information.
		Content []ChatCompletionTokenLogprob `json:"content"`

		// Refusal A list of message refusal tokens with log probability information.
		Refusal []ChatCompletionTokenLogprob `json:"refusal"`
	} `json:"logprobs,omitempty"`
}

ChatCompletionStreamChoice defines model for ChatCompletionStreamChoice.

type ChatCompletionStreamOptions added in v1.5.0

type ChatCompletionStreamOptions struct {
	// IncludeUsage If set, an additional chunk will be streamed before the `data: [DONE]` message. The `usage` field on this chunk shows the token usage statistics for the entire request, and the `choices` field will always be an empty array. All other chunks will also include a `usage` field, but with a null value.
	IncludeUsage bool `json:"include_usage"`
}

ChatCompletionStreamOptions Options for streaming response. Only set this when you set `stream: true`.

type ChatCompletionStreamResponseDelta added in v1.5.0

type ChatCompletionStreamResponseDelta struct {
	// Content The contents of the chunk message.
	Content string `json:"content"`

	// Reasoning The reasoning of the chunk message. Same as reasoning_content.
	Reasoning *string `json:"reasoning,omitempty"`

	// ReasoningContent The reasoning content of the chunk message.
	ReasoningContent *string `json:"reasoning_content,omitempty"`

	// Refusal The refusal message generated by the model.
	Refusal *string `json:"refusal,omitempty"`

	// Role Role of the message sender
	Role      MessageRole                           `json:"role"`
	ToolCalls *[]ChatCompletionMessageToolCallChunk `json:"tool_calls,omitempty"`
}

ChatCompletionStreamResponseDelta A chat completion delta generated by streamed model responses.

type ChatCompletionTokenLogprob added in v1.5.0

type ChatCompletionTokenLogprob struct {
	// Bytes A list of integers representing the UTF-8 bytes representation of the token. Useful in instances where characters are represented by multiple tokens and their byte representations must be combined to generate the correct text representation. Can be `null` if there is no bytes representation for the token.
	Bytes []int `json:"bytes"`

	// Logprob The log probability of this token, if it is within the top 20 most likely tokens. Otherwise, the value `-9999.0` is used to signify that the token is very unlikely.
	Logprob float32 `json:"logprob"`

	// Token The token.
	Token string `json:"token"`

	// TopLogprobs List of the most likely tokens and their log probability, at this token position. In rare cases, there may be fewer than the number of requested `top_logprobs` returned.
	TopLogprobs []struct {
		// Bytes A list of integers representing the UTF-8 bytes representation of the token. Useful in instances where characters are represented by multiple tokens and their byte representations must be combined to generate the correct text representation. Can be `null` if there is no bytes representation for the token.
		Bytes []int `json:"bytes"`

		// Logprob The log probability of this token, if it is within the top 20 most likely tokens. Otherwise, the value `-9999.0` is used to signify that the token is very unlikely.
		Logprob float32 `json:"logprob"`

		// Token The token.
		Token string `json:"token"`
	} `json:"top_logprobs"`
}

ChatCompletionTokenLogprob defines model for ChatCompletionTokenLogprob.

type ChatCompletionTool added in v1.5.0

type ChatCompletionTool struct {
	Function FunctionObject `json:"function"`

	// Type The type of the tool. Currently, only `function` is supported.
	Type ChatCompletionToolType `json:"type"`
}

ChatCompletionTool defines model for ChatCompletionTool.

type ChatCompletionToolChoiceOption added in v1.18.0

type ChatCompletionToolChoiceOption struct {
	// contains filtered or unexported fields
}

ChatCompletionToolChoiceOption Controls which (if any) tool is called by the model. `none` means the model will not call any tool and instead generates a message. `auto` means the model can pick between generating a message or calling one or more tools. `required` means the model must call one or more tools. Specifying a particular tool via `{"type": "function", "function": {"name": "my_function"}}` forces the model to call that tool. `none` is the default when no tools are present. `auto` is the default if tools are present.

func (ChatCompletionToolChoiceOption) AsChatCompletionNamedToolChoice added in v1.18.0

func (t ChatCompletionToolChoiceOption) AsChatCompletionNamedToolChoice() (ChatCompletionNamedToolChoice, error)

AsChatCompletionNamedToolChoice returns the union data inside the ChatCompletionToolChoiceOption as a ChatCompletionNamedToolChoice

func (ChatCompletionToolChoiceOption) AsChatCompletionToolChoiceOption0 added in v1.18.0

func (t ChatCompletionToolChoiceOption) AsChatCompletionToolChoiceOption0() (ChatCompletionToolChoiceOption0, error)

AsChatCompletionToolChoiceOption0 returns the union data inside the ChatCompletionToolChoiceOption as a ChatCompletionToolChoiceOption0

func (*ChatCompletionToolChoiceOption) FromChatCompletionNamedToolChoice added in v1.18.0

func (t *ChatCompletionToolChoiceOption) FromChatCompletionNamedToolChoice(v ChatCompletionNamedToolChoice) error

FromChatCompletionNamedToolChoice overwrites any union data inside the ChatCompletionToolChoiceOption as the provided ChatCompletionNamedToolChoice

func (*ChatCompletionToolChoiceOption) FromChatCompletionToolChoiceOption0 added in v1.18.0

func (t *ChatCompletionToolChoiceOption) FromChatCompletionToolChoiceOption0(v ChatCompletionToolChoiceOption0) error

FromChatCompletionToolChoiceOption0 overwrites any union data inside the ChatCompletionToolChoiceOption as the provided ChatCompletionToolChoiceOption0

func (ChatCompletionToolChoiceOption) MarshalJSON added in v1.18.0

func (t ChatCompletionToolChoiceOption) MarshalJSON() ([]byte, error)

func (*ChatCompletionToolChoiceOption) MergeChatCompletionNamedToolChoice added in v1.18.0

func (t *ChatCompletionToolChoiceOption) MergeChatCompletionNamedToolChoice(v ChatCompletionNamedToolChoice) error

MergeChatCompletionNamedToolChoice performs a merge with any union data inside the ChatCompletionToolChoiceOption, using the provided ChatCompletionNamedToolChoice

func (*ChatCompletionToolChoiceOption) MergeChatCompletionToolChoiceOption0 added in v1.18.0

func (t *ChatCompletionToolChoiceOption) MergeChatCompletionToolChoiceOption0(v ChatCompletionToolChoiceOption0) error

MergeChatCompletionToolChoiceOption0 performs a merge with any union data inside the ChatCompletionToolChoiceOption, using the provided ChatCompletionToolChoiceOption0

func (*ChatCompletionToolChoiceOption) UnmarshalJSON added in v1.18.0

func (t *ChatCompletionToolChoiceOption) UnmarshalJSON(b []byte) error

type ChatCompletionToolChoiceOption0 added in v1.18.0

type ChatCompletionToolChoiceOption0 string

ChatCompletionToolChoiceOption0 `none` means the model will not call any tool and instead generates a message. `auto` means the model can pick between generating a message or calling one or more tools. `required` means the model must call one or more tools.

const (
	ChatCompletionToolChoiceOption0Auto     ChatCompletionToolChoiceOption0 = "auto"
	ChatCompletionToolChoiceOption0None     ChatCompletionToolChoiceOption0 = "none"
	ChatCompletionToolChoiceOption0Required ChatCompletionToolChoiceOption0 = "required"
)

Defines values for ChatCompletionToolChoiceOption0.

func (ChatCompletionToolChoiceOption0) Valid added in v1.18.0

Valid indicates whether the value is a known member of the ChatCompletionToolChoiceOption0 enum.

type ChatCompletionToolType added in v1.5.0

type ChatCompletionToolType string

ChatCompletionToolType The type of the tool. Currently, only `function` is supported.

const (
	Function ChatCompletionToolType = "function"
)

Defines values for ChatCompletionToolType.

func (ChatCompletionToolType) Valid added in v1.16.0

func (e ChatCompletionToolType) Valid() bool

Valid indicates whether the value is a known member of the ChatCompletionToolType enum.

type Client

type Client interface {
	WithAuthToken(token string) Client
	WithTools(tools *[]ChatCompletionTool) Client
	WithOptions(options *CreateChatCompletionRequest) Client
	WithHeaders(headers map[string]string) Client
	WithHeader(name, value string) Client
	WithMiddlewareOptions(options *MiddlewareOptions) Client
	ListModels(ctx context.Context, include ...ListModelsParamsInclude) (*ListModelsResponse, error)
	ListProviderModels(ctx context.Context, provider Provider, include ...ListModelsParamsInclude) (*ListModelsResponse, error)
	ListTools(ctx context.Context) (*ListToolsResponse, error)
	GenerateContent(ctx context.Context, provider Provider, model string, messages []Message) (*CreateChatCompletionResponse, error)
	GenerateContentStream(ctx context.Context, provider Provider, model string, messages []Message) (<-chan SSEvent, error)
	CreateMessage(ctx context.Context, provider Provider, request CreateMessagesRequest) (*MessagesResponse, error)
	CreateMessageStream(ctx context.Context, provider Provider, request CreateMessagesRequest) (<-chan SSEvent, error)
	CreateImage(ctx context.Context, provider Provider, request CreateImageRequest) (*ImagesResponse, error)
	CreateImageEdit(ctx context.Context, provider Provider, request CreateImageEditMultipartBody) (*ImagesResponse, error)
	CreateImageVariation(ctx context.Context, provider Provider, request CreateImageVariationMultipartBody) (*ImagesResponse, error)
	HealthCheck(ctx context.Context) error
}

Client represents the SDK client interface

func NewClient

func NewClient(options *ClientOptions) Client

NewClient creates a new SDK client with the specified options.

Example:

client := sdk.NewClient(&sdk.ClientOptions{
	BaseURL: "http://localhost:8080/v1",
	APIKey: "your-api-key",
	Timeout: 30 * time.Second,
	Tools: nil,
	Headers: map[string]string{
		"X-Custom-Header": "custom-value",
		"User-Agent": "my-app/1.0",
	},
})

type ClientOptions added in v1.5.1

type ClientOptions struct {
	// APIKey is the API key to use for the client.
	APIKey string
	// BaseURL is the base URL to use for the client.
	BaseURL string
	// Timeout is the timeout to use for the client.
	Timeout time.Duration
	// Tools is the tools to use for the client.
	Tools *[]ChatCompletionTool
	// Headers is a map of custom headers to include with all requests.
	Headers map[string]string
	// RetryConfig is the retry configuration for HTTP requests.
	RetryConfig *RetryConfig
	// Transport, when set, overrides the client's HTTP transport. Use it to
	// inject an http.RoundTripper - e.g. one that propagates W3C trace-context
	// headers so gateway calls join the caller's distributed trace.
	Transport http.RoundTripper
}

ClientOptions represents the options that can be passed to the client.

type CompletionUsage added in v1.5.0

type CompletionUsage struct {
	// CompletionTokens Number of tokens in the generated completion.
	CompletionTokens int64 `json:"completion_tokens"`

	// CompletionTokensDetails Breakdown of tokens used in a completion.
	CompletionTokensDetails *struct {
		// AcceptedPredictionTokens When using Predicted Outputs, the number of tokens in the prediction that appeared in the completion.
		AcceptedPredictionTokens *int64 `json:"accepted_prediction_tokens,omitempty"`

		// AudioTokens Audio input tokens generated by the model.
		AudioTokens *int64 `json:"audio_tokens,omitempty"`

		// ReasoningTokens Tokens generated by the model for reasoning.
		ReasoningTokens *int64 `json:"reasoning_tokens,omitempty"`

		// RejectedPredictionTokens When using Predicted Outputs, the number of tokens in the prediction that did not appear in the completion. However, like reasoning tokens, these tokens are still counted in the total completion tokens for purposes of billing, output, and context window limits.
		RejectedPredictionTokens *int64 `json:"rejected_prediction_tokens,omitempty"`
	} `json:"completion_tokens_details,omitempty"`

	// PromptTokens Number of tokens in the prompt.
	PromptTokens int64 `json:"prompt_tokens"`

	// PromptTokensDetails Breakdown of tokens used in the prompt.
	PromptTokensDetails *struct {
		// AudioTokens Audio input tokens present in the prompt.
		AudioTokens *int64 `json:"audio_tokens,omitempty"`

		// CachedTokens Cached tokens present in the prompt.
		CachedTokens *int64 `json:"cached_tokens,omitempty"`
	} `json:"prompt_tokens_details,omitempty"`

	// TotalTokens Total number of tokens used in the request (prompt + completion).
	TotalTokens int64 `json:"total_tokens"`
}

CompletionUsage Usage statistics for the completion request.

type ContentPart added in v1.14.0

type ContentPart struct {
	// contains filtered or unexported fields
}

ContentPart A content part within a multimodal message

func NewImageContentPart added in v1.14.0

func NewImageContentPart(imageURL string, detail *ImageURLDetail) (ContentPart, error)

NewImageContentPart creates an image content part for multimodal messages.

func NewTextContentPart added in v1.14.0

func NewTextContentPart(text string) (ContentPart, error)

NewTextContentPart creates a text content part for multimodal messages.

func (ContentPart) AsImageContentPart added in v1.14.0

func (t ContentPart) AsImageContentPart() (ImageContentPart, error)

AsImageContentPart returns the union data inside the ContentPart as a ImageContentPart

func (ContentPart) AsTextContentPart added in v1.14.0

func (t ContentPart) AsTextContentPart() (TextContentPart, error)

AsTextContentPart returns the union data inside the ContentPart as a TextContentPart

func (*ContentPart) FromImageContentPart added in v1.14.0

func (t *ContentPart) FromImageContentPart(v ImageContentPart) error

FromImageContentPart overwrites any union data inside the ContentPart as the provided ImageContentPart

func (*ContentPart) FromTextContentPart added in v1.14.0

func (t *ContentPart) FromTextContentPart(v TextContentPart) error

FromTextContentPart overwrites any union data inside the ContentPart as the provided TextContentPart

func (ContentPart) MarshalJSON added in v1.14.0

func (t ContentPart) MarshalJSON() ([]byte, error)

func (*ContentPart) MergeImageContentPart added in v1.14.0

func (t *ContentPart) MergeImageContentPart(v ImageContentPart) error

MergeImageContentPart performs a merge with any union data inside the ContentPart, using the provided ImageContentPart

func (*ContentPart) MergeTextContentPart added in v1.14.0

func (t *ContentPart) MergeTextContentPart(v TextContentPart) error

MergeTextContentPart performs a merge with any union data inside the ContentPart, using the provided TextContentPart

func (*ContentPart) UnmarshalJSON added in v1.14.0

func (t *ContentPart) UnmarshalJSON(b []byte) error

type ContextWindow added in v1.24.0

type ContextWindow struct {
	// Source Source of the context window information
	Source ContextWindowSource `json:"source"`

	// Tokens Maximum number of tokens the model can process in a single request
	Tokens int `json:"tokens"`
}

ContextWindow Context window information for a model

type ContextWindowSource added in v1.25.0

type ContextWindowSource string

ContextWindowSource Source of the context window information

const (
	ContextWindowSourceCommunity ContextWindowSource = "community"
	ContextWindowSourceProvider  ContextWindowSource = "provider"
	ContextWindowSourceRuntime   ContextWindowSource = "runtime"
)

Defines values for ContextWindowSource.

func (ContextWindowSource) Valid added in v1.25.0

func (e ContextWindowSource) Valid() bool

Valid indicates whether the value is a known member of the ContextWindowSource enum.

type CreateChatCompletionJSONRequestBody added in v1.5.0

type CreateChatCompletionJSONRequestBody = CreateChatCompletionRequest

CreateChatCompletionJSONRequestBody defines body for CreateChatCompletion for application/json ContentType.

type CreateChatCompletionParams added in v1.5.0

type CreateChatCompletionParams struct {
	// Provider Specific provider to use (default determined by model)
	Provider *Provider `form:"provider,omitempty" json:"provider,omitempty"`
}

CreateChatCompletionParams defines parameters for CreateChatCompletion.

type CreateChatCompletionRequest added in v1.5.0

type CreateChatCompletionRequest struct {
	// FrequencyPenalty Number between -2.0 and 2.0. Positive values penalize new tokens based on their existing frequency in the text so far, decreasing the model's likelihood to repeat the same line verbatim.
	FrequencyPenalty *float32 `json:"frequency_penalty,omitempty"`

	// LogitBias Modify the likelihood of specified tokens appearing in the completion. Accepts a JSON object that maps tokens (specified by their token ID in the tokenizer) to an associated bias value from -100 to 100. The bias is added to the logits generated by the model prior to sampling.
	LogitBias *map[string]int `json:"logit_bias,omitempty"`

	// Logprobs Whether to return log probabilities of the output tokens or not. If true, returns the log probabilities of each output token returned in the `content` of `message`.
	Logprobs *bool `json:"logprobs,omitempty"`

	// MaxCompletionTokens An upper bound for the number of tokens that can be generated for a completion, including visible output tokens and reasoning tokens.
	MaxCompletionTokens *int `json:"max_completion_tokens,omitempty"`

	// MaxTokens The maximum number of tokens that can be generated in the chat completion. This value can be used to control costs for text generated via API. This value is now deprecated in favor of `max_completion_tokens`, and is not compatible with o-series models.
	// Deprecated: this property has been marked as deprecated upstream, but no `x-deprecated-reason` was set
	MaxTokens *int `json:"max_tokens,omitempty"`

	// Messages A list of messages comprising the conversation so far.
	Messages []Message `json:"messages"`

	// Model Model ID to use
	Model string `json:"model"`

	// N How many chat completion choices to generate for each input message.
	N *int `json:"n,omitempty"`

	// ParallelToolCalls Whether to enable parallel function calling during tool use.
	ParallelToolCalls *bool `json:"parallel_tool_calls,omitempty"`

	// PresencePenalty Number between -2.0 and 2.0. Positive values penalize new tokens based on whether they appear in the text so far, increasing the model's likelihood to talk about new topics.
	PresencePenalty *float32 `json:"presence_penalty,omitempty"`

	// ReasoningEffort Constrains effort on reasoning for reasoning models. Currently supported values are `minimal`, `low`, `medium`, and `high`. Reducing reasoning effort can result in faster responses and fewer tokens used on reasoning in a response.
	ReasoningEffort *CreateChatCompletionRequestReasoningEffort `json:"reasoning_effort,omitempty"`

	// ReasoningFormat The format of the reasoning content. Can be `raw` or `parsed`.
	// When specified as raw some reasoning models will output <think /> tags. When specified as parsed the model will output the reasoning under `reasoning` or `reasoning_content` attribute.
	ReasoningFormat *string `json:"reasoning_format,omitempty"`

	// ResponseFormat An object specifying the format that the model must output. Setting to `{ "type": "json_schema", "json_schema": {...} }` enables Structured Outputs which guarantees the model will match your supplied JSON schema. Setting to `{ "type": "json_object" }` enables the older JSON mode, which ensures the message the model generates is valid JSON.
	ResponseFormat *CreateChatCompletionRequest_ResponseFormat `json:"response_format,omitempty"`

	// Seed If specified, our system will make a best effort to sample deterministically, such that repeated requests with the same `seed` and parameters should return the same result. Determinism is not guaranteed, and you should refer to the `system_fingerprint` response parameter to monitor changes in the backend.
	Seed *int `json:"seed,omitempty"`

	// Stop Up to 4 sequences where the API will stop generating further tokens.
	Stop *CreateChatCompletionRequest_Stop `json:"stop,omitempty"`

	// Stream If set to true, the model response data will be streamed to the client as it is generated using [server-sent events](https://developer.mozilla.org/en-US/docs/Web/API/Server-sent_events/Using_server-sent_events#Event_stream_format).
	Stream *bool `json:"stream,omitempty"`

	// StreamOptions Options for streaming response. Only set this when you set `stream: true`.
	StreamOptions *ChatCompletionStreamOptions `json:"stream_options,omitempty"`

	// Temperature What sampling temperature to use, between 0 and 2. Higher values like 0.8 will make the output more random, while lower values like 0.2 will make it more focused and deterministic.
	Temperature *float32 `json:"temperature,omitempty"`

	// ToolChoice Controls which (if any) tool is called by the model. `none` means the model will not call any tool and instead generates a message. `auto` means the model can pick between generating a message or calling one or more tools. `required` means the model must call one or more tools. Specifying a particular tool via `{"type": "function", "function": {"name": "my_function"}}` forces the model to call that tool.
	// `none` is the default when no tools are present. `auto` is the default if tools are present.
	ToolChoice *ChatCompletionToolChoiceOption `json:"tool_choice,omitempty"`

	// Tools A list of tools the model may call. Currently, only functions are supported as a tool. Use this to provide a list of functions the model may generate JSON inputs for. A max of 128 functions are supported.
	Tools *[]ChatCompletionTool `json:"tools,omitempty"`

	// TopLogprobs An integer between 0 and 20 specifying the number of most likely tokens to return at each token position, each with an associated log probability. `logprobs` must be set to `true` if this parameter is used.
	TopLogprobs *int `json:"top_logprobs,omitempty"`

	// TopP An alternative to sampling with temperature, called nucleus sampling, where the model considers the results of the tokens with top_p probability mass.
	TopP *float32 `json:"top_p,omitempty"`

	// User A unique identifier representing your end-user, which can help to monitor and detect abuse.
	User *string `json:"user,omitempty"`
}

CreateChatCompletionRequest defines model for CreateChatCompletionRequest.

type CreateChatCompletionRequestReasoningEffort added in v1.18.0

type CreateChatCompletionRequestReasoningEffort string

CreateChatCompletionRequestReasoningEffort Constrains effort on reasoning for reasoning models. Currently supported values are `minimal`, `low`, `medium`, and `high`. Reducing reasoning effort can result in faster responses and fewer tokens used on reasoning in a response.

const (
	CreateChatCompletionRequestReasoningEffortHigh    CreateChatCompletionRequestReasoningEffort = "high"
	CreateChatCompletionRequestReasoningEffortLow     CreateChatCompletionRequestReasoningEffort = "low"
	CreateChatCompletionRequestReasoningEffortMedium  CreateChatCompletionRequestReasoningEffort = "medium"
	CreateChatCompletionRequestReasoningEffortMinimal CreateChatCompletionRequestReasoningEffort = "minimal"
)

Defines values for CreateChatCompletionRequestReasoningEffort.

func (CreateChatCompletionRequestReasoningEffort) Valid added in v1.18.0

Valid indicates whether the value is a known member of the CreateChatCompletionRequestReasoningEffort enum.

type CreateChatCompletionRequestStop0 added in v1.18.0

type CreateChatCompletionRequestStop0 = string

CreateChatCompletionRequestStop0 defines model for CreateChatCompletionRequest.Stop.0.

type CreateChatCompletionRequestStop1 added in v1.18.0

type CreateChatCompletionRequestStop1 = []string

CreateChatCompletionRequestStop1 defines model for CreateChatCompletionRequest.Stop.1.

type CreateChatCompletionRequest_ResponseFormat added in v1.18.0

type CreateChatCompletionRequest_ResponseFormat struct {
	// contains filtered or unexported fields
}

CreateChatCompletionRequest_ResponseFormat An object specifying the format that the model must output. Setting to `{ "type": "json_schema", "json_schema": {...} }` enables Structured Outputs which guarantees the model will match your supplied JSON schema. Setting to `{ "type": "json_object" }` enables the older JSON mode, which ensures the message the model generates is valid JSON.

func (CreateChatCompletionRequest_ResponseFormat) AsResponseFormatJSONObject added in v1.18.0

AsResponseFormatJSONObject returns the union data inside the CreateChatCompletionRequest_ResponseFormat as a ResponseFormatJSONObject

func (CreateChatCompletionRequest_ResponseFormat) AsResponseFormatJSONSchema added in v1.18.0

AsResponseFormatJSONSchema returns the union data inside the CreateChatCompletionRequest_ResponseFormat as a ResponseFormatJSONSchema

func (CreateChatCompletionRequest_ResponseFormat) AsResponseFormatText added in v1.18.0

AsResponseFormatText returns the union data inside the CreateChatCompletionRequest_ResponseFormat as a ResponseFormatText

func (*CreateChatCompletionRequest_ResponseFormat) FromResponseFormatJSONObject added in v1.18.0

FromResponseFormatJSONObject overwrites any union data inside the CreateChatCompletionRequest_ResponseFormat as the provided ResponseFormatJSONObject

func (*CreateChatCompletionRequest_ResponseFormat) FromResponseFormatJSONSchema added in v1.18.0

FromResponseFormatJSONSchema overwrites any union data inside the CreateChatCompletionRequest_ResponseFormat as the provided ResponseFormatJSONSchema

func (*CreateChatCompletionRequest_ResponseFormat) FromResponseFormatText added in v1.18.0

FromResponseFormatText overwrites any union data inside the CreateChatCompletionRequest_ResponseFormat as the provided ResponseFormatText

func (CreateChatCompletionRequest_ResponseFormat) MarshalJSON added in v1.18.0

func (*CreateChatCompletionRequest_ResponseFormat) MergeResponseFormatJSONObject added in v1.18.0

MergeResponseFormatJSONObject performs a merge with any union data inside the CreateChatCompletionRequest_ResponseFormat, using the provided ResponseFormatJSONObject

func (*CreateChatCompletionRequest_ResponseFormat) MergeResponseFormatJSONSchema added in v1.18.0

MergeResponseFormatJSONSchema performs a merge with any union data inside the CreateChatCompletionRequest_ResponseFormat, using the provided ResponseFormatJSONSchema

func (*CreateChatCompletionRequest_ResponseFormat) MergeResponseFormatText added in v1.18.0

MergeResponseFormatText performs a merge with any union data inside the CreateChatCompletionRequest_ResponseFormat, using the provided ResponseFormatText

func (*CreateChatCompletionRequest_ResponseFormat) UnmarshalJSON added in v1.18.0

type CreateChatCompletionRequest_Stop added in v1.18.0

type CreateChatCompletionRequest_Stop struct {
	// contains filtered or unexported fields
}

CreateChatCompletionRequest_Stop Up to 4 sequences where the API will stop generating further tokens.

func (CreateChatCompletionRequest_Stop) AsCreateChatCompletionRequestStop0 added in v1.18.0

func (t CreateChatCompletionRequest_Stop) AsCreateChatCompletionRequestStop0() (CreateChatCompletionRequestStop0, error)

AsCreateChatCompletionRequestStop0 returns the union data inside the CreateChatCompletionRequest_Stop as a CreateChatCompletionRequestStop0

func (CreateChatCompletionRequest_Stop) AsCreateChatCompletionRequestStop1 added in v1.18.0

func (t CreateChatCompletionRequest_Stop) AsCreateChatCompletionRequestStop1() (CreateChatCompletionRequestStop1, error)

AsCreateChatCompletionRequestStop1 returns the union data inside the CreateChatCompletionRequest_Stop as a CreateChatCompletionRequestStop1

func (*CreateChatCompletionRequest_Stop) FromCreateChatCompletionRequestStop0 added in v1.18.0

func (t *CreateChatCompletionRequest_Stop) FromCreateChatCompletionRequestStop0(v CreateChatCompletionRequestStop0) error

FromCreateChatCompletionRequestStop0 overwrites any union data inside the CreateChatCompletionRequest_Stop as the provided CreateChatCompletionRequestStop0

func (*CreateChatCompletionRequest_Stop) FromCreateChatCompletionRequestStop1 added in v1.18.0

func (t *CreateChatCompletionRequest_Stop) FromCreateChatCompletionRequestStop1(v CreateChatCompletionRequestStop1) error

FromCreateChatCompletionRequestStop1 overwrites any union data inside the CreateChatCompletionRequest_Stop as the provided CreateChatCompletionRequestStop1

func (CreateChatCompletionRequest_Stop) MarshalJSON added in v1.18.0

func (t CreateChatCompletionRequest_Stop) MarshalJSON() ([]byte, error)

func (*CreateChatCompletionRequest_Stop) MergeCreateChatCompletionRequestStop0 added in v1.18.0

func (t *CreateChatCompletionRequest_Stop) MergeCreateChatCompletionRequestStop0(v CreateChatCompletionRequestStop0) error

MergeCreateChatCompletionRequestStop0 performs a merge with any union data inside the CreateChatCompletionRequest_Stop, using the provided CreateChatCompletionRequestStop0

func (*CreateChatCompletionRequest_Stop) MergeCreateChatCompletionRequestStop1 added in v1.18.0

func (t *CreateChatCompletionRequest_Stop) MergeCreateChatCompletionRequestStop1(v CreateChatCompletionRequestStop1) error

MergeCreateChatCompletionRequestStop1 performs a merge with any union data inside the CreateChatCompletionRequest_Stop, using the provided CreateChatCompletionRequestStop1

func (*CreateChatCompletionRequest_Stop) UnmarshalJSON added in v1.18.0

func (t *CreateChatCompletionRequest_Stop) UnmarshalJSON(b []byte) error

type CreateChatCompletionResponse added in v1.5.0

type CreateChatCompletionResponse struct {
	// Choices A list of chat completion choices. Can be more than one if `n` is greater than 1.
	Choices []ChatCompletionChoice `json:"choices"`

	// Created The Unix timestamp (in seconds) of when the chat completion was created.
	Created int `json:"created"`

	// ID A unique identifier for the chat completion.
	ID string `json:"id"`

	// Model The model used for the chat completion.
	Model string `json:"model"`

	// Object The object type, which is always `chat.completion`.
	Object string `json:"object"`

	// Usage Usage statistics for the completion request.
	Usage *CompletionUsage `json:"usage,omitempty"`
}

CreateChatCompletionResponse Represents a chat completion response returned by model, based on the provided input.

type CreateChatCompletionStreamResponse added in v1.5.0

type CreateChatCompletionStreamResponse struct {
	// Choices A list of chat completion choices. Can contain more than one elements if `n` is greater than 1. Can also be empty for the
	// last chunk if you set `stream_options: {"include_usage": true}`.
	Choices []ChatCompletionStreamChoice `json:"choices"`

	// Created The Unix timestamp (in seconds) of when the chat completion was created. Each chunk has the same timestamp.
	Created int `json:"created"`

	// ID A unique identifier for the chat completion. Each chunk has the same ID.
	ID string `json:"id"`

	// Model The model to generate the completion.
	Model string `json:"model"`

	// Object The object type, which is always `chat.completion.chunk`.
	Object string `json:"object"`

	// ReasoningFormat The format of the reasoning content. Can be `raw` or `parsed`.
	// When specified as raw some reasoning models will output <think /> tags. When specified as parsed the model will output the reasoning under reasoning_content.
	ReasoningFormat *string `json:"reasoning_format,omitempty"`

	// SystemFingerprint This fingerprint represents the backend configuration that the model runs with.
	// Can be used in conjunction with the `seed` request parameter to understand when backend changes have been made that might impact determinism.
	SystemFingerprint *string `json:"system_fingerprint,omitempty"`

	// Usage Usage statistics for the completion request.
	Usage *CompletionUsage `json:"usage,omitempty"`
}

CreateChatCompletionStreamResponse Represents a streamed chunk of a chat completion response returned by the model, based on the provided input.

type CreateImageEditMultipartBody added in v1.33.0

type CreateImageEditMultipartBody struct {
	// Image The image to edit. For the GPT image models, a `png`, `webp`, or `jpg` file up to 50MB; for `dall-e-2`, a square PNG under 4MB. If `mask` is not provided, the image must have transparency, which will be used as the mask.
	Image openapi_types.File `json:"image"`

	// Mask An additional image whose fully transparent areas (alpha = 0) indicate where the image should be edited. Must be a valid PNG file with the same dimensions as the image (under 4MB for `dall-e-2`).
	Mask *openapi_types.File `json:"mask,omitempty"`

	// Model Model ID to use for image editing.
	Model *string `json:"model,omitempty"`

	// N Number of images to generate.
	N *int `json:"n,omitempty"`

	// Prompt A text description of the desired image.
	Prompt string `json:"prompt"`

	// Quality The quality of the edited image. `auto` selects the best
	// quality for the model. The GPT image models support `low`,
	// `medium`, and `high`; `dall-e-2` supports only `standard`.
	Quality *CreateImageEditMultipartBodyQuality `json:"quality,omitempty"`

	// ResponseFormat The format in which the generated images are returned.
	ResponseFormat *CreateImageEditMultipartBodyResponseFormat `json:"response_format,omitempty"`

	// Size The size of the generated images. The GPT image models support
	// `1024x1024`, `1536x1024`, `1024x1536`, and `auto`; `gpt-image-2`
	// also accepts arbitrary `WIDTHxHEIGHT` values such as `1536x864`.
	// `dall-e-2` supports `256x256`, `512x512`, and `1024x1024`;
	// `dall-e-3` supports `1024x1024`, `1792x1024`, and `1024x1792`.
	Size *ImageSize `json:"size,omitempty"`
}

CreateImageEditMultipartBody defines parameters for CreateImageEdit.

type CreateImageEditMultipartBodyQuality added in v1.33.0

type CreateImageEditMultipartBodyQuality string

CreateImageEditMultipartBodyQuality defines parameters for CreateImageEdit.

const (
	CreateImageEditMultipartBodyQualityAuto     CreateImageEditMultipartBodyQuality = "auto"
	CreateImageEditMultipartBodyQualityHigh     CreateImageEditMultipartBodyQuality = "high"
	CreateImageEditMultipartBodyQualityLow      CreateImageEditMultipartBodyQuality = "low"
	CreateImageEditMultipartBodyQualityMedium   CreateImageEditMultipartBodyQuality = "medium"
	CreateImageEditMultipartBodyQualityStandard CreateImageEditMultipartBodyQuality = "standard"
)

Defines values for CreateImageEditMultipartBodyQuality.

func (CreateImageEditMultipartBodyQuality) Valid added in v1.33.0

Valid indicates whether the value is a known member of the CreateImageEditMultipartBodyQuality enum.

type CreateImageEditMultipartBodyResponseFormat added in v1.33.0

type CreateImageEditMultipartBodyResponseFormat string

CreateImageEditMultipartBodyResponseFormat defines parameters for CreateImageEdit.

const (
	CreateImageEditMultipartBodyResponseFormatB64Json CreateImageEditMultipartBodyResponseFormat = "b64_json"
	CreateImageEditMultipartBodyResponseFormatURL     CreateImageEditMultipartBodyResponseFormat = "url"
)

Defines values for CreateImageEditMultipartBodyResponseFormat.

func (CreateImageEditMultipartBodyResponseFormat) Valid added in v1.33.0

Valid indicates whether the value is a known member of the CreateImageEditMultipartBodyResponseFormat enum.

type CreateImageEditMultipartRequestBody added in v1.33.0

type CreateImageEditMultipartRequestBody CreateImageEditMultipartBody

CreateImageEditMultipartRequestBody defines body for CreateImageEdit for multipart/form-data ContentType.

type CreateImageEditParams added in v1.33.0

type CreateImageEditParams struct {
	// Provider Specific provider to use (default determined by model)
	Provider *Provider `form:"provider,omitempty" json:"provider,omitempty"`
}

CreateImageEditParams defines parameters for CreateImageEdit.

type CreateImageJSONRequestBody added in v1.31.0

type CreateImageJSONRequestBody = CreateImageRequest

CreateImageJSONRequestBody defines body for CreateImage for application/json ContentType.

type CreateImageParams added in v1.31.0

type CreateImageParams struct {
	// Provider Specific provider to use (default determined by model)
	Provider *Provider `form:"provider,omitempty" json:"provider,omitempty"`
}

CreateImageParams defines parameters for CreateImage.

type CreateImageRequest added in v1.31.0

type CreateImageRequest struct {
	// Model Model ID to use for image generation.
	Model *string `json:"model,omitempty"`

	// N Number of images to generate.
	N *int `json:"n,omitempty"`

	// Prompt A text description of the desired image.
	Prompt string `json:"prompt"`

	// Quality The quality of the image. `auto` selects the best quality for
	// the model. The GPT image models support `low`, `medium`, and
	// `high`; `dall-e-3` supports `standard` and `hd`; `dall-e-2`
	// supports only `standard`.
	Quality *CreateImageRequestQuality `json:"quality,omitempty"`

	// ResponseFormat The format in which the generated images are returned. Must be
	// one of `url` or `b64_json`.
	ResponseFormat *CreateImageRequestResponseFormat `json:"response_format,omitempty"`

	// Size The size of the generated images. The GPT image models support
	// `1024x1024`, `1536x1024`, `1024x1536`, and `auto`; `gpt-image-2`
	// also accepts arbitrary `WIDTHxHEIGHT` values such as `1536x864`.
	// `dall-e-2` supports `256x256`, `512x512`, and `1024x1024`;
	// `dall-e-3` supports `1024x1024`, `1792x1024`, and `1024x1792`.
	Size *ImageSize `json:"size,omitempty"`
}

CreateImageRequest Request body for creating an image via the OpenAI-compatible Images API.

type CreateImageRequestQuality added in v1.32.0

type CreateImageRequestQuality string

CreateImageRequestQuality The quality of the image. `auto` selects the best quality for the model. The GPT image models support `low`, `medium`, and `high`; `dall-e-3` supports `standard` and `hd`; `dall-e-2` supports only `standard`.

const (
	CreateImageRequestQualityAuto     CreateImageRequestQuality = "auto"
	CreateImageRequestQualityHd       CreateImageRequestQuality = "hd"
	CreateImageRequestQualityHigh     CreateImageRequestQuality = "high"
	CreateImageRequestQualityLow      CreateImageRequestQuality = "low"
	CreateImageRequestQualityMedium   CreateImageRequestQuality = "medium"
	CreateImageRequestQualityStandard CreateImageRequestQuality = "standard"
)

Defines values for CreateImageRequestQuality.

func (CreateImageRequestQuality) Valid added in v1.32.0

func (e CreateImageRequestQuality) Valid() bool

Valid indicates whether the value is a known member of the CreateImageRequestQuality enum.

type CreateImageRequestResponseFormat added in v1.31.0

type CreateImageRequestResponseFormat string

CreateImageRequestResponseFormat The format in which the generated images are returned. Must be one of `url` or `b64_json`.

const (
	CreateImageRequestResponseFormatB64Json CreateImageRequestResponseFormat = "b64_json"
	CreateImageRequestResponseFormatURL     CreateImageRequestResponseFormat = "url"
)

Defines values for CreateImageRequestResponseFormat.

func (CreateImageRequestResponseFormat) Valid added in v1.31.0

Valid indicates whether the value is a known member of the CreateImageRequestResponseFormat enum.

type CreateImageVariationMultipartBody added in v1.33.0

type CreateImageVariationMultipartBody struct {
	// Image The image to use as the basis for the variation. For the GPT image models, a `png`, `webp`, or `jpg` file up to 50MB; for `dall-e-2`, a square PNG under 4MB.
	Image openapi_types.File `json:"image"`

	// Model Model ID to use for image variation.
	Model *string `json:"model,omitempty"`

	// N Number of images to generate.
	N *int `json:"n,omitempty"`

	// ResponseFormat The format in which the generated images are returned.
	ResponseFormat *CreateImageVariationMultipartBodyResponseFormat `json:"response_format,omitempty"`

	// Size The size of the generated images. The GPT image models support
	// `1024x1024`, `1536x1024`, `1024x1536`, and `auto`; `gpt-image-2`
	// also accepts arbitrary `WIDTHxHEIGHT` values such as `1536x864`.
	// `dall-e-2` supports `256x256`, `512x512`, and `1024x1024`;
	// `dall-e-3` supports `1024x1024`, `1792x1024`, and `1024x1792`.
	Size *ImageSize `json:"size,omitempty"`
}

CreateImageVariationMultipartBody defines parameters for CreateImageVariation.

type CreateImageVariationMultipartBodyResponseFormat added in v1.33.0

type CreateImageVariationMultipartBodyResponseFormat string

CreateImageVariationMultipartBodyResponseFormat defines parameters for CreateImageVariation.

const (
	CreateImageVariationMultipartBodyResponseFormatB64Json CreateImageVariationMultipartBodyResponseFormat = "b64_json"
	CreateImageVariationMultipartBodyResponseFormatURL     CreateImageVariationMultipartBodyResponseFormat = "url"
)

Defines values for CreateImageVariationMultipartBodyResponseFormat.

func (CreateImageVariationMultipartBodyResponseFormat) Valid added in v1.33.0

Valid indicates whether the value is a known member of the CreateImageVariationMultipartBodyResponseFormat enum.

type CreateImageVariationMultipartRequestBody added in v1.33.0

type CreateImageVariationMultipartRequestBody CreateImageVariationMultipartBody

CreateImageVariationMultipartRequestBody defines body for CreateImageVariation for multipart/form-data ContentType.

type CreateImageVariationParams added in v1.33.0

type CreateImageVariationParams struct {
	// Provider Specific provider to use (default determined by model)
	Provider *Provider `form:"provider,omitempty" json:"provider,omitempty"`
}

CreateImageVariationParams defines parameters for CreateImageVariation.

type CreateMessageJSONRequestBody added in v1.26.0

type CreateMessageJSONRequestBody = CreateMessagesRequest

CreateMessageJSONRequestBody defines body for CreateMessage for application/json ContentType.

type CreateMessageParams added in v1.26.0

type CreateMessageParams struct {
	// Provider Specific provider to use (default determined by model)
	Provider *Provider `form:"provider,omitempty" json:"provider,omitempty"`
}

CreateMessageParams defines parameters for CreateMessage.

type CreateMessagesRequest added in v1.26.0

type CreateMessagesRequest struct {
	// MaxTokens The maximum number of tokens to generate before stopping.
	MaxTokens int `json:"max_tokens"`

	// Messages The messages to generate a response for. Each message has a
	// `role` (user or assistant) and `content`.
	Messages []MessagesMessage `json:"messages"`

	// Metadata Metadata for a Messages API request.
	Metadata *MessagesMetadata `json:"metadata,omitempty"`

	// Model The model to use for generating the message.
	Model string `json:"model"`

	// OutputConfig Output configuration for a Messages API request.
	OutputConfig *MessagesOutputConfig `json:"output_config,omitempty"`

	// StopSequences Custom text sequences that will cause the model to stop
	// generating.
	StopSequences *[]string `json:"stop_sequences,omitempty"`

	// Stream Whether to stream the response using server-sent events.
	Stream *bool `json:"stream,omitempty"`

	// System The system prompt. Can be a string or an array of system content
	// blocks (for prompt caching).
	System *CreateMessagesRequest_System `json:"system,omitempty"`

	// Temperature Amount of randomness injected into the response. Ranges from
	// 0.0 to 1.0. Use closer to 0 for analytical / multiple choice,
	// closer to 1 for creative and generative tasks.
	Temperature *float32 `json:"temperature,omitempty"`

	// Thinking Configuration for extended thinking.
	Thinking *struct {
		// BudgetTokens The maximum number of tokens the model is allowed to use
		// for thinking.
		BudgetTokens int `json:"budget_tokens"`

		// Type Always `enabled`.
		Type CreateMessagesRequestThinkingType `json:"type"`
	} `json:"thinking,omitempty"`

	// ToolChoice Controls which (if any) tool is called by the model. `auto` means
	// the model can decide, `any` means the model must use a tool, and
	// `tool` forces a specific tool.
	ToolChoice *MessagesToolChoice `json:"tool_choice,omitempty"`

	// Tools Definitions of tools the model may call. Each tool can include
	// `cache_control` for prompt caching.
	Tools *[]MessagesTool `json:"tools,omitempty"`

	// TopK Only sample from the top K options for each subsequent token.
	TopK *int `json:"top_k,omitempty"`

	// TopP Use nucleus sampling. Only consider the tokens with top_p
	// probability mass.
	TopP *float32 `json:"top_p,omitempty"`
}

CreateMessagesRequest Request body for creating a message via the Anthropic-compatible Messages API.

type CreateMessagesRequestSystem0 added in v1.26.0

type CreateMessagesRequestSystem0 = string

CreateMessagesRequestSystem0 System prompt as a string.

type CreateMessagesRequestSystem1 added in v1.26.0

type CreateMessagesRequestSystem1 = []MessagesTextBlock

CreateMessagesRequestSystem1 defines model for CreateMessagesRequest.System.1.

type CreateMessagesRequestThinkingType added in v1.26.0

type CreateMessagesRequestThinkingType string

CreateMessagesRequestThinkingType Always `enabled`.

const (
	Enabled CreateMessagesRequestThinkingType = "enabled"
)

Defines values for CreateMessagesRequestThinkingType.

func (CreateMessagesRequestThinkingType) Valid added in v1.26.0

Valid indicates whether the value is a known member of the CreateMessagesRequestThinkingType enum.

type CreateMessagesRequest_System added in v1.26.0

type CreateMessagesRequest_System struct {
	// contains filtered or unexported fields
}

CreateMessagesRequest_System The system prompt. Can be a string or an array of system content blocks (for prompt caching).

func (CreateMessagesRequest_System) AsCreateMessagesRequestSystem0 added in v1.26.0

func (t CreateMessagesRequest_System) AsCreateMessagesRequestSystem0() (CreateMessagesRequestSystem0, error)

AsCreateMessagesRequestSystem0 returns the union data inside the CreateMessagesRequest_System as a CreateMessagesRequestSystem0

func (CreateMessagesRequest_System) AsCreateMessagesRequestSystem1 added in v1.26.0

func (t CreateMessagesRequest_System) AsCreateMessagesRequestSystem1() (CreateMessagesRequestSystem1, error)

AsCreateMessagesRequestSystem1 returns the union data inside the CreateMessagesRequest_System as a CreateMessagesRequestSystem1

func (*CreateMessagesRequest_System) FromCreateMessagesRequestSystem0 added in v1.26.0

func (t *CreateMessagesRequest_System) FromCreateMessagesRequestSystem0(v CreateMessagesRequestSystem0) error

FromCreateMessagesRequestSystem0 overwrites any union data inside the CreateMessagesRequest_System as the provided CreateMessagesRequestSystem0

func (*CreateMessagesRequest_System) FromCreateMessagesRequestSystem1 added in v1.26.0

func (t *CreateMessagesRequest_System) FromCreateMessagesRequestSystem1(v CreateMessagesRequestSystem1) error

FromCreateMessagesRequestSystem1 overwrites any union data inside the CreateMessagesRequest_System as the provided CreateMessagesRequestSystem1

func (CreateMessagesRequest_System) MarshalJSON added in v1.26.0

func (t CreateMessagesRequest_System) MarshalJSON() ([]byte, error)

func (*CreateMessagesRequest_System) MergeCreateMessagesRequestSystem0 added in v1.26.0

func (t *CreateMessagesRequest_System) MergeCreateMessagesRequestSystem0(v CreateMessagesRequestSystem0) error

MergeCreateMessagesRequestSystem0 performs a merge with any union data inside the CreateMessagesRequest_System, using the provided CreateMessagesRequestSystem0

func (*CreateMessagesRequest_System) MergeCreateMessagesRequestSystem1 added in v1.26.0

func (t *CreateMessagesRequest_System) MergeCreateMessagesRequestSystem1(v CreateMessagesRequestSystem1) error

MergeCreateMessagesRequestSystem1 performs a merge with any union data inside the CreateMessagesRequest_System, using the provided CreateMessagesRequestSystem1

func (*CreateMessagesRequest_System) UnmarshalJSON added in v1.26.0

func (t *CreateMessagesRequest_System) UnmarshalJSON(b []byte) error

type CreateResponseJSONRequestBody added in v1.20.0

type CreateResponseJSONRequestBody = CreateResponseRequest

CreateResponseJSONRequestBody defines body for CreateResponse for application/json ContentType.

type CreateResponseParams added in v1.20.0

type CreateResponseParams struct {
	// Provider Specific provider to use (default determined by model)
	Provider *Provider `form:"provider,omitempty" json:"provider,omitempty"`
}

CreateResponseParams defines parameters for CreateResponse.

type CreateResponseRequest added in v1.20.0

type CreateResponseRequest struct {
	// Background Whether to run the model response in the background. Useful for long-running or batched requests.
	Background *bool `json:"background,omitempty"`

	// Input Text, image, or file inputs to the model. Either a single text prompt or a list of input items representing a (possibly batched) conversation.
	Input ResponseInput `json:"input"`

	// Instructions A system (or developer) message inserted into the model's context. When used with `previous_response_id`, instructions from previous responses are not carried over.
	Instructions *string `json:"instructions,omitempty"`

	// MaxOutputTokens An upper bound for the number of tokens that can be generated for a response, including visible output tokens and reasoning tokens.
	MaxOutputTokens *int `json:"max_output_tokens,omitempty"`

	// Metadata Set of up to 16 key-value pairs that can be attached to the object and returned when retrieving the response.
	Metadata *map[string]string `json:"metadata,omitempty"`

	// Model Model ID used to generate the response.
	Model string `json:"model"`

	// ParallelToolCalls Whether to allow the model to run tool calls in parallel.
	ParallelToolCalls *bool `json:"parallel_tool_calls,omitempty"`

	// PreviousResponseID The unique ID of the previous response to the model. Use this to create multi-turn conversations.
	PreviousResponseID *string `json:"previous_response_id,omitempty"`

	// Reasoning Configuration options for reasoning models.
	Reasoning *ResponseReasoning `json:"reasoning,omitempty"`

	// Store Whether to store the generated model response for later retrieval.
	Store *bool `json:"store,omitempty"`

	// Stream If set to true, the model response data is streamed to the client as it is generated using [server-sent events](https://developer.mozilla.org/en-US/docs/Web/API/Server-sent_events/Using_server-sent_events#Event_stream_format).
	Stream *bool `json:"stream,omitempty"`

	// Temperature What sampling temperature to use, between 0 and 2. Higher values make the output more random; lower values make it more focused.
	Temperature *float32 `json:"temperature,omitempty"`

	// Text Configuration options for a text response from the model. Can be plain text or structured JSON data.
	Text *ResponseTextConfig `json:"text,omitempty"`

	// ToolChoice How the model should select which tool (or tools) to use. Either a mode string (`none`, `auto`, `required`) or an object forcing a specific tool.
	ToolChoice *ResponseToolChoice `json:"tool_choice,omitempty"`

	// Tools An array of tools the model may call while generating a response.
	Tools *[]ResponseTool `json:"tools,omitempty"`

	// TopP An alternative to sampling with temperature, called nucleus sampling, where the model considers the tokens with `top_p` probability mass.
	TopP *float32 `json:"top_p,omitempty"`

	// User A stable identifier for your end-users, used to help detect and prevent abuse.
	User *string `json:"user,omitempty"`
}

CreateResponseRequest Request body for creating a model response via the Responses API.

type Error added in v1.5.0

type Error struct {
	Error *string `json:"error,omitempty"`
}

Error defines model for Error.

type FinishReason added in v1.15.0

type FinishReason string

FinishReason The reason the model stopped generating tokens. This will be `stop` if the model hit a natural stop point or a provided stop sequence, `length` if the maximum number of tokens specified in the request was reached, `content_filter` if content was omitted due to a flag from our content filters, `tool_calls` if the model called a tool.

const (
	ContentFilter FinishReason = "content_filter"
	FunctionCall  FinishReason = "function_call"
	Length        FinishReason = "length"
	Stop          FinishReason = "stop"
	ToolCalls     FinishReason = "tool_calls"
)

Defines values for FinishReason.

func (FinishReason) Valid added in v1.16.0

func (e FinishReason) Valid() bool

Valid indicates whether the value is a known member of the FinishReason enum.

type FunctionObject added in v1.5.0

type FunctionObject struct {
	// Description A description of what the function does, used by the model to choose when and how to call the function.
	Description *string `json:"description,omitempty"`

	// Name The name of the function to be called. Must be a-z, A-Z, 0-9, or contain underscores and dashes, with a maximum length of 64.
	Name string `json:"name"`

	// Parameters The parameters the functions accepts, described as a JSON Schema object. See the [guide](/docs/guides/function-calling) for examples, and the [JSON Schema reference](https://json-schema.org/understanding-json-schema/) for documentation about the format.
	// Omitting `parameters` defines a function with an empty parameter list.
	Parameters *FunctionParameters `json:"parameters,omitempty"`

	// Strict Whether to enable strict schema adherence when generating the function call. If set to true, the model will follow the exact schema defined in the `parameters` field. Only a subset of JSON Schema is supported when `strict` is `true`. Learn more about Structured Outputs in the [function calling guide](docs/guides/function-calling).
	Strict *bool `json:"strict,omitempty"`
}

FunctionObject defines model for FunctionObject.

type FunctionParameters added in v1.5.0

type FunctionParameters map[string]any

FunctionParameters The parameters the functions accepts, described as a JSON Schema object. See the [guide](/docs/guides/function-calling) for examples, and the [JSON Schema reference](https://json-schema.org/understanding-json-schema/) for documentation about the format. Omitting `parameters` defines a function with an empty parameter list.

type Image added in v1.26.0

type Image struct {
	// B64Json The base64-encoded JSON of the generated image, if
	// `response_format` is `b64_json`.
	B64Json *string `json:"b64_json,omitempty"`

	// RevisedPrompt The prompt that was used to generate the image, if there was any
	// revision to the prompt.
	RevisedPrompt *string `json:"revised_prompt,omitempty"`

	// URL The URL of the generated image, if `response_format` is `url`
	// (default).
	URL *string `json:"url,omitempty"`
}

Image Represents the url or the content of an image generated by the Images API.

type ImageContentPart added in v1.14.0

type ImageContentPart struct {
	// ImageURL Image URL configuration
	ImageURL ImageURL `json:"image_url"`

	// Type Content type identifier
	Type ImageContentPartType `json:"type"`
}

ImageContentPart Image content part

type ImageContentPartType added in v1.14.0

type ImageContentPartType string

ImageContentPartType Content type identifier

const (
	ImageContentPartTypeImageURL ImageContentPartType = "image_url"
)

Defines values for ImageContentPartType.

func (ImageContentPartType) Valid added in v1.16.0

func (e ImageContentPartType) Valid() bool

Valid indicates whether the value is a known member of the ImageContentPartType enum.

type ImageSize added in v1.32.0

type ImageSize string

ImageSize The size of the generated images. The GPT image models support `1024x1024`, `1536x1024`, `1024x1536`, and `auto`; `gpt-image-2` also accepts arbitrary `WIDTHxHEIGHT` values such as `1536x864`. `dall-e-2` supports `256x256`, `512x512`, and `1024x1024`; `dall-e-3` supports `1024x1024`, `1792x1024`, and `1024x1792`.

const (
	ImageSize1024X1024 ImageSize = "1024x1024"
	ImageSize1024X1536 ImageSize = "1024x1536"
	ImageSize1024X1792 ImageSize = "1024x1792"
	ImageSize1536X1024 ImageSize = "1536x1024"
	ImageSize1792X1024 ImageSize = "1792x1024"
	ImageSize256X256   ImageSize = "256x256"
	ImageSize512X512   ImageSize = "512x512"
	ImageSizeAuto      ImageSize = "auto"
)

Defines values for ImageSize.

func (ImageSize) Valid added in v1.32.0

func (e ImageSize) Valid() bool

Valid indicates whether the value is a known member of the ImageSize enum.

type ImageURL added in v1.14.0

type ImageURL struct {
	// Detail Image detail level for vision processing
	Detail *ImageURLDetail `json:"detail,omitempty"`

	// URL URL of the image (data URLs supported)
	URL string `json:"url"`
}

ImageURL Image URL configuration

type ImageURLDetail added in v1.14.0

type ImageURLDetail string

ImageURLDetail Image detail level for vision processing

const (
	ImageURLDetailAuto ImageURLDetail = "auto"
	ImageURLDetailHigh ImageURLDetail = "high"
	ImageURLDetailLow  ImageURLDetail = "low"
)

Defines values for ImageURLDetail.

func (ImageURLDetail) Valid added in v1.16.0

func (e ImageURLDetail) Valid() bool

Valid indicates whether the value is a known member of the ImageURLDetail enum.

type ImagesNotSupported added in v1.31.0

type ImagesNotSupported = Error

ImagesNotSupported defines model for ImagesNotSupported.

type ImagesResponse added in v1.31.0

type ImagesResponse struct {
	// Created The Unix timestamp (in seconds) of when the image was created.
	Created int64 `json:"created"`

	// Data The generated images.
	Data []Image `json:"data"`

	// Usage Usage statistics for the image generation request.
	Usage *struct {
		// InputTokens Number of input tokens.
		InputTokens *int64 `json:"input_tokens,omitempty"`

		// InputTokensDetails A detailed breakdown of the input tokens.
		InputTokensDetails *struct {
			// CachedTokens The number of tokens retrieved from the cache.
			CachedTokens *int64 `json:"cached_tokens,omitempty"`
		} `json:"input_tokens_details,omitempty"`

		// OutputTokens Number of output tokens.
		OutputTokens *int64 `json:"output_tokens,omitempty"`

		// TotalTokens Total number of tokens used.
		TotalTokens *int64 `json:"total_tokens,omitempty"`
	} `json:"usage,omitempty"`
}

ImagesResponse Represents the result of an image generation request.

type InternalError added in v1.5.0

type InternalError = Error

InternalError defines model for InternalError.

type ListModelsParams added in v1.5.0

type ListModelsParams struct {
	// Provider Specific provider to query (optional)
	Provider *Provider `form:"provider,omitempty" json:"provider,omitempty"`

	// Include Comma-separated list of metadata keys to include in the response.
	// Supported values: `pricing`, `context_window`, `modalities`.
	// When omitted, the response remains unchanged (backward compatible).
	Include *[]ListModelsParamsInclude `form:"include,omitempty" json:"include,omitempty"`
}

ListModelsParams defines parameters for ListModels.

type ListModelsParamsInclude added in v1.24.0

type ListModelsParamsInclude string

ListModelsParamsInclude defines parameters for ListModels.

const (
	ListModelsParamsIncludeContextWindow ListModelsParamsInclude = "context_window"
	ListModelsParamsIncludeModalities    ListModelsParamsInclude = "modalities"
	ListModelsParamsIncludePricing       ListModelsParamsInclude = "pricing"
)

Defines values for ListModelsParamsInclude.

func (ListModelsParamsInclude) Valid added in v1.24.0

func (e ListModelsParamsInclude) Valid() bool

Valid indicates whether the value is a known member of the ListModelsParamsInclude enum.

type ListModelsResponse added in v1.3.0

type ListModelsResponse struct {
	Data     []Model   `json:"data"`
	Object   string    `json:"object"`
	Provider *Provider `json:"provider,omitempty"`
}

ListModelsResponse Response structure for listing models

type ListToolsResponse added in v1.8.0

type ListToolsResponse struct {
	// Data Array of available MCP tools
	Data []MCPTool `json:"data"`

	// Object Always "list"
	Object string `json:"object"`
}

ListToolsResponse Response structure for listing MCP tools

type MCPNotExposed added in v1.8.0

type MCPNotExposed = Error

MCPNotExposed defines model for MCPNotExposed.

type MCPTool added in v1.8.0

type MCPTool struct {
	// Description A description of what the tool does
	Description string `json:"description"`

	// InputSchema JSON schema for the tool's input parameters
	InputSchema *map[string]any `json:"input_schema,omitempty"`

	// Name The name of the tool
	Name string `json:"name"`

	// Server The MCP server that provides this tool
	Server string `json:"server"`
}

MCPTool An MCP tool definition

type Message

type Message struct {
	// Content Message content - either text or multimodal content parts
	Content MessageContent `json:"content"`

	// Reasoning The reasoning of the chunk message. Same as reasoning_content.
	Reasoning *string `json:"reasoning,omitempty"`

	// ReasoningContent The reasoning content of the chunk message.
	ReasoningContent *string `json:"reasoning_content,omitempty"`

	// Role Role of the message sender
	Role       MessageRole                      `json:"role"`
	ToolCallID *string                          `json:"tool_call_id,omitempty"`
	ToolCalls  *[]ChatCompletionMessageToolCall `json:"tool_calls,omitempty"`
}

Message Message structure for provider requests

func NewImageMessage added in v1.14.0

func NewImageMessage(role MessageRole, parts []ContentPart) (Message, error)

NewImageMessage creates a message with multimodal content (text + images).

func NewTextMessage added in v1.14.0

func NewTextMessage(role MessageRole, text string) (Message, error)

NewTextMessage creates a message with text content (backward compatible).

type MessageContent added in v1.14.1

type MessageContent struct {
	// contains filtered or unexported fields
}

MessageContent Message content - either text or multimodal content parts

func NewMessageContent added in v1.14.0

func NewMessageContent[T string | []ContentPart](value T) MessageContent

NewMessageContent creates MessageContent from either a string or []ContentPart. This provides backward compatibility similar to OpenAI's SDK pattern.

Usage:

content := NewMessageContent("Hello world")              // string
content := NewMessageContent([]ContentPart{...})         // multimodal

func (MessageContent) AsMessageContent0 added in v1.14.1

func (t MessageContent) AsMessageContent0() (MessageContent0, error)

AsMessageContent0 returns the union data inside the MessageContent as a MessageContent0

func (MessageContent) AsMessageContent1 added in v1.14.1

func (t MessageContent) AsMessageContent1() (MessageContent1, error)

AsMessageContent1 returns the union data inside the MessageContent as a MessageContent1

func (*MessageContent) FromMessageContent0 added in v1.14.1

func (t *MessageContent) FromMessageContent0(v MessageContent0) error

FromMessageContent0 overwrites any union data inside the MessageContent as the provided MessageContent0

func (*MessageContent) FromMessageContent1 added in v1.14.1

func (t *MessageContent) FromMessageContent1(v MessageContent1) error

FromMessageContent1 overwrites any union data inside the MessageContent as the provided MessageContent1

func (MessageContent) MarshalJSON added in v1.14.1

func (t MessageContent) MarshalJSON() ([]byte, error)

func (*MessageContent) MergeMessageContent0 added in v1.14.1

func (t *MessageContent) MergeMessageContent0(v MessageContent0) error

MergeMessageContent0 performs a merge with any union data inside the MessageContent, using the provided MessageContent0

func (*MessageContent) MergeMessageContent1 added in v1.14.1

func (t *MessageContent) MergeMessageContent1(v MessageContent1) error

MergeMessageContent1 performs a merge with any union data inside the MessageContent, using the provided MessageContent1

func (*MessageContent) UnmarshalJSON added in v1.14.1

func (t *MessageContent) UnmarshalJSON(b []byte) error

type MessageContent0 added in v1.14.0

type MessageContent0 = string

MessageContent0 Text content (backward compatibility)

type MessageContent1 added in v1.14.0

type MessageContent1 = []ContentPart

MessageContent1 Array of content parts for multimodal messages

type MessageRole added in v1.5.0

type MessageRole string

MessageRole Role of the message sender

const (
	Assistant MessageRole = "assistant"
	System    MessageRole = "system"
	Tool      MessageRole = "tool"
	User      MessageRole = "user"
)

Defines values for MessageRole.

func (MessageRole) Valid added in v1.16.0

func (e MessageRole) Valid() bool

Valid indicates whether the value is a known member of the MessageRole enum.

type MessagesDocumentBlock added in v1.26.0

type MessagesDocumentBlock struct {
	// CacheControl Cache control settings for prompt caching. Currently only
	// `ephemeral` caching is supported.
	CacheControl *CacheControl `json:"cache_control,omitempty"`

	// Source The source of a document content block. Can be a base64-encoded
	// document or a URL.
	Source MessagesDocumentSource `json:"source"`

	// Type Content type identifier. Always `document`.
	Type MessagesDocumentBlockType `json:"type"`
}

MessagesDocumentBlock A document content block in a Messages API request.

type MessagesDocumentBlockType added in v1.26.0

type MessagesDocumentBlockType string

MessagesDocumentBlockType Content type identifier. Always `document`.

const (
	Document MessagesDocumentBlockType = "document"
)

Defines values for MessagesDocumentBlockType.

func (MessagesDocumentBlockType) Valid added in v1.26.0

func (e MessagesDocumentBlockType) Valid() bool

Valid indicates whether the value is a known member of the MessagesDocumentBlockType enum.

type MessagesDocumentSource added in v1.26.0

type MessagesDocumentSource struct {
	// Data Base64-encoded document data. Required when `type` is `base64`.
	Data *string `json:"data,omitempty"`

	// MediaType The media type of the document (e.g. `application/pdf`).
	// Required when `type` is `base64`.
	MediaType *string `json:"media_type,omitempty"`

	// Type The source type.
	Type MessagesDocumentSourceType `json:"type"`

	// URL URL of the document. Required when `type` is `url`.
	URL *string `json:"url,omitempty"`
}

MessagesDocumentSource The source of a document content block. Can be a base64-encoded document or a URL.

type MessagesDocumentSourceType added in v1.26.0

type MessagesDocumentSourceType string

MessagesDocumentSourceType The source type.

const (
	MessagesDocumentSourceTypeBase64 MessagesDocumentSourceType = "base64"
	MessagesDocumentSourceTypeURL    MessagesDocumentSourceType = "url"
)

Defines values for MessagesDocumentSourceType.

func (MessagesDocumentSourceType) Valid added in v1.26.0

func (e MessagesDocumentSourceType) Valid() bool

Valid indicates whether the value is a known member of the MessagesDocumentSourceType enum.

type MessagesError added in v1.26.0

type MessagesError struct {
	// Error The error details.
	Error struct {
		// Message A human-readable error message.
		Message string `json:"message"`

		// Type The error type (e.g. `invalid_request_error`, `api_error`).
		Type string `json:"type"`
	} `json:"error"`

	// Type Always `error`.
	Type MessagesErrorType `json:"type"`
}

MessagesError An error response in the Anthropic error format.

type MessagesErrorType added in v1.26.0

type MessagesErrorType string

MessagesErrorType Always `error`.

const (
	MessagesErrorTypeError MessagesErrorType = "error"
)

Defines values for MessagesErrorType.

func (MessagesErrorType) Valid added in v1.26.0

func (e MessagesErrorType) Valid() bool

Valid indicates whether the value is a known member of the MessagesErrorType enum.

type MessagesImageBlock added in v1.26.0

type MessagesImageBlock struct {
	// CacheControl Cache control settings for prompt caching. Currently only
	// `ephemeral` caching is supported.
	CacheControl *CacheControl `json:"cache_control,omitempty"`

	// Source The source of an image content block. Can be a base64-encoded
	// image or a URL.
	Source MessagesImageSource `json:"source"`

	// Type Content type identifier. Always `image`.
	Type MessagesImageBlockType `json:"type"`
}

MessagesImageBlock An image content block in a Messages API request.

type MessagesImageBlockType added in v1.26.0

type MessagesImageBlockType string

MessagesImageBlockType Content type identifier. Always `image`.

const (
	MessagesImageBlockTypeImage MessagesImageBlockType = "image"
)

Defines values for MessagesImageBlockType.

func (MessagesImageBlockType) Valid added in v1.26.0

func (e MessagesImageBlockType) Valid() bool

Valid indicates whether the value is a known member of the MessagesImageBlockType enum.

type MessagesImageSource added in v1.26.0

type MessagesImageSource struct {
	// Data Base64-encoded image data. Required when `type` is `base64`.
	Data *string `json:"data,omitempty"`

	// MediaType The media type of the image (e.g. `image/jpeg`, `image/png`,
	// `image/gif`, `image/webp`). Required when `type` is `base64`.
	MediaType *string `json:"media_type,omitempty"`

	// Type The source type.
	Type MessagesImageSourceType `json:"type"`

	// URL URL of the image. Required when `type` is `url`.
	URL *string `json:"url,omitempty"`
}

MessagesImageSource The source of an image content block. Can be a base64-encoded image or a URL.

type MessagesImageSourceType added in v1.26.0

type MessagesImageSourceType string

MessagesImageSourceType The source type.

const (
	MessagesImageSourceTypeBase64 MessagesImageSourceType = "base64"
	MessagesImageSourceTypeURL    MessagesImageSourceType = "url"
)

Defines values for MessagesImageSourceType.

func (MessagesImageSourceType) Valid added in v1.26.0

func (e MessagesImageSourceType) Valid() bool

Valid indicates whether the value is a known member of the MessagesImageSourceType enum.

type MessagesMessage added in v1.26.0

type MessagesMessage struct {
	// Content The content of the message. Can be a string or an array of
	// content blocks.
	Content MessagesMessage_Content `json:"content"`

	// Role The role of the message sender.
	Role MessagesMessageRole `json:"role"`
}

MessagesMessage A message in a Messages API request.

type MessagesMessageContent0 added in v1.26.0

type MessagesMessageContent0 = string

MessagesMessageContent0 Text content.

type MessagesMessageContent1 added in v1.26.0

type MessagesMessageContent1 = []MessagesRequestContentBlock

MessagesMessageContent1 defines model for MessagesMessage.Content.1.

type MessagesMessageRole added in v1.26.0

type MessagesMessageRole string

MessagesMessageRole The role of the message sender.

const (
	MessagesMessageRoleAssistant MessagesMessageRole = "assistant"
	MessagesMessageRoleUser      MessagesMessageRole = "user"
)

Defines values for MessagesMessageRole.

func (MessagesMessageRole) Valid added in v1.26.0

func (e MessagesMessageRole) Valid() bool

Valid indicates whether the value is a known member of the MessagesMessageRole enum.

type MessagesMessage_Content added in v1.26.0

type MessagesMessage_Content struct {
	// contains filtered or unexported fields
}

MessagesMessage_Content The content of the message. Can be a string or an array of content blocks.

func (MessagesMessage_Content) AsMessagesMessageContent0 added in v1.26.0

func (t MessagesMessage_Content) AsMessagesMessageContent0() (MessagesMessageContent0, error)

AsMessagesMessageContent0 returns the union data inside the MessagesMessage_Content as a MessagesMessageContent0

func (MessagesMessage_Content) AsMessagesMessageContent1 added in v1.26.0

func (t MessagesMessage_Content) AsMessagesMessageContent1() (MessagesMessageContent1, error)

AsMessagesMessageContent1 returns the union data inside the MessagesMessage_Content as a MessagesMessageContent1

func (*MessagesMessage_Content) FromMessagesMessageContent0 added in v1.26.0

func (t *MessagesMessage_Content) FromMessagesMessageContent0(v MessagesMessageContent0) error

FromMessagesMessageContent0 overwrites any union data inside the MessagesMessage_Content as the provided MessagesMessageContent0

func (*MessagesMessage_Content) FromMessagesMessageContent1 added in v1.26.0

func (t *MessagesMessage_Content) FromMessagesMessageContent1(v MessagesMessageContent1) error

FromMessagesMessageContent1 overwrites any union data inside the MessagesMessage_Content as the provided MessagesMessageContent1

func (MessagesMessage_Content) MarshalJSON added in v1.26.0

func (t MessagesMessage_Content) MarshalJSON() ([]byte, error)

func (*MessagesMessage_Content) MergeMessagesMessageContent0 added in v1.26.0

func (t *MessagesMessage_Content) MergeMessagesMessageContent0(v MessagesMessageContent0) error

MergeMessagesMessageContent0 performs a merge with any union data inside the MessagesMessage_Content, using the provided MessagesMessageContent0

func (*MessagesMessage_Content) MergeMessagesMessageContent1 added in v1.26.0

func (t *MessagesMessage_Content) MergeMessagesMessageContent1(v MessagesMessageContent1) error

MergeMessagesMessageContent1 performs a merge with any union data inside the MessagesMessage_Content, using the provided MessagesMessageContent1

func (*MessagesMessage_Content) UnmarshalJSON added in v1.26.0

func (t *MessagesMessage_Content) UnmarshalJSON(b []byte) error

type MessagesMetadata added in v1.26.0

type MessagesMetadata struct {
	// UserID An external identifier for the user.
	UserID *string `json:"user_id,omitempty"`
}

MessagesMetadata Metadata for a Messages API request.

type MessagesNotSupported added in v1.26.0

type MessagesNotSupported = MessagesError

MessagesNotSupported An error response in the Anthropic error format.

type MessagesOutputConfig added in v1.30.0

type MessagesOutputConfig struct {
	// Effort Constrains how much effort the model spends on reasoning.
	// Lower effort yields faster responses and fewer reasoning
	// tokens.
	Effort *MessagesOutputConfigEffort `json:"effort,omitempty"`
}

MessagesOutputConfig Output configuration for a Messages API request.

type MessagesOutputConfigEffort added in v1.30.0

type MessagesOutputConfigEffort string

MessagesOutputConfigEffort Constrains how much effort the model spends on reasoning. Lower effort yields faster responses and fewer reasoning tokens.

const (
	MessagesOutputConfigEffortHigh   MessagesOutputConfigEffort = "high"
	MessagesOutputConfigEffortLow    MessagesOutputConfigEffort = "low"
	MessagesOutputConfigEffortMax    MessagesOutputConfigEffort = "max"
	MessagesOutputConfigEffortMedium MessagesOutputConfigEffort = "medium"
	MessagesOutputConfigEffortXhigh  MessagesOutputConfigEffort = "xhigh"
)

Defines values for MessagesOutputConfigEffort.

func (MessagesOutputConfigEffort) Valid added in v1.30.0

func (e MessagesOutputConfigEffort) Valid() bool

Valid indicates whether the value is a known member of the MessagesOutputConfigEffort enum.

type MessagesRedactedThinkingBlock added in v1.26.0

type MessagesRedactedThinkingBlock struct {
	// Data The encrypted thinking content.
	Data string `json:"data"`

	// Type Content type identifier. Always `redacted_thinking`.
	Type MessagesRedactedThinkingBlockType `json:"type"`
}

MessagesRedactedThinkingBlock A redacted thinking content block in a Messages API request or response. Emitted when thinking content is encrypted for safety reasons; must be passed back unchanged in multi-turn conversations.

type MessagesRedactedThinkingBlockType added in v1.26.0

type MessagesRedactedThinkingBlockType string

MessagesRedactedThinkingBlockType Content type identifier. Always `redacted_thinking`.

const (
	RedactedThinking MessagesRedactedThinkingBlockType = "redacted_thinking"
)

Defines values for MessagesRedactedThinkingBlockType.

func (MessagesRedactedThinkingBlockType) Valid added in v1.26.0

Valid indicates whether the value is a known member of the MessagesRedactedThinkingBlockType enum.

type MessagesRequestContentBlock added in v1.26.0

type MessagesRequestContentBlock struct {
	// contains filtered or unexported fields
}

MessagesRequestContentBlock A content block within a Messages API request message.

func (MessagesRequestContentBlock) AsMessagesDocumentBlock added in v1.26.0

func (t MessagesRequestContentBlock) AsMessagesDocumentBlock() (MessagesDocumentBlock, error)

AsMessagesDocumentBlock returns the union data inside the MessagesRequestContentBlock as a MessagesDocumentBlock

func (MessagesRequestContentBlock) AsMessagesImageBlock added in v1.26.0

func (t MessagesRequestContentBlock) AsMessagesImageBlock() (MessagesImageBlock, error)

AsMessagesImageBlock returns the union data inside the MessagesRequestContentBlock as a MessagesImageBlock

func (MessagesRequestContentBlock) AsMessagesRedactedThinkingBlock added in v1.26.0

func (t MessagesRequestContentBlock) AsMessagesRedactedThinkingBlock() (MessagesRedactedThinkingBlock, error)

AsMessagesRedactedThinkingBlock returns the union data inside the MessagesRequestContentBlock as a MessagesRedactedThinkingBlock

func (MessagesRequestContentBlock) AsMessagesTextBlock added in v1.26.0

func (t MessagesRequestContentBlock) AsMessagesTextBlock() (MessagesTextBlock, error)

AsMessagesTextBlock returns the union data inside the MessagesRequestContentBlock as a MessagesTextBlock

func (MessagesRequestContentBlock) AsMessagesThinkingBlock added in v1.26.0

func (t MessagesRequestContentBlock) AsMessagesThinkingBlock() (MessagesThinkingBlock, error)

AsMessagesThinkingBlock returns the union data inside the MessagesRequestContentBlock as a MessagesThinkingBlock

func (MessagesRequestContentBlock) AsMessagesToolResultBlock added in v1.26.0

func (t MessagesRequestContentBlock) AsMessagesToolResultBlock() (MessagesToolResultBlock, error)

AsMessagesToolResultBlock returns the union data inside the MessagesRequestContentBlock as a MessagesToolResultBlock

func (MessagesRequestContentBlock) AsMessagesToolUseBlock added in v1.26.0

func (t MessagesRequestContentBlock) AsMessagesToolUseBlock() (MessagesToolUseBlock, error)

AsMessagesToolUseBlock returns the union data inside the MessagesRequestContentBlock as a MessagesToolUseBlock

func (*MessagesRequestContentBlock) FromMessagesDocumentBlock added in v1.26.0

func (t *MessagesRequestContentBlock) FromMessagesDocumentBlock(v MessagesDocumentBlock) error

FromMessagesDocumentBlock overwrites any union data inside the MessagesRequestContentBlock as the provided MessagesDocumentBlock

func (*MessagesRequestContentBlock) FromMessagesImageBlock added in v1.26.0

func (t *MessagesRequestContentBlock) FromMessagesImageBlock(v MessagesImageBlock) error

FromMessagesImageBlock overwrites any union data inside the MessagesRequestContentBlock as the provided MessagesImageBlock

func (*MessagesRequestContentBlock) FromMessagesRedactedThinkingBlock added in v1.26.0

func (t *MessagesRequestContentBlock) FromMessagesRedactedThinkingBlock(v MessagesRedactedThinkingBlock) error

FromMessagesRedactedThinkingBlock overwrites any union data inside the MessagesRequestContentBlock as the provided MessagesRedactedThinkingBlock

func (*MessagesRequestContentBlock) FromMessagesTextBlock added in v1.26.0

func (t *MessagesRequestContentBlock) FromMessagesTextBlock(v MessagesTextBlock) error

FromMessagesTextBlock overwrites any union data inside the MessagesRequestContentBlock as the provided MessagesTextBlock

func (*MessagesRequestContentBlock) FromMessagesThinkingBlock added in v1.26.0

func (t *MessagesRequestContentBlock) FromMessagesThinkingBlock(v MessagesThinkingBlock) error

FromMessagesThinkingBlock overwrites any union data inside the MessagesRequestContentBlock as the provided MessagesThinkingBlock

func (*MessagesRequestContentBlock) FromMessagesToolResultBlock added in v1.26.0

func (t *MessagesRequestContentBlock) FromMessagesToolResultBlock(v MessagesToolResultBlock) error

FromMessagesToolResultBlock overwrites any union data inside the MessagesRequestContentBlock as the provided MessagesToolResultBlock

func (*MessagesRequestContentBlock) FromMessagesToolUseBlock added in v1.26.0

func (t *MessagesRequestContentBlock) FromMessagesToolUseBlock(v MessagesToolUseBlock) error

FromMessagesToolUseBlock overwrites any union data inside the MessagesRequestContentBlock as the provided MessagesToolUseBlock

func (MessagesRequestContentBlock) MarshalJSON added in v1.26.0

func (t MessagesRequestContentBlock) MarshalJSON() ([]byte, error)

func (*MessagesRequestContentBlock) MergeMessagesDocumentBlock added in v1.26.0

func (t *MessagesRequestContentBlock) MergeMessagesDocumentBlock(v MessagesDocumentBlock) error

MergeMessagesDocumentBlock performs a merge with any union data inside the MessagesRequestContentBlock, using the provided MessagesDocumentBlock

func (*MessagesRequestContentBlock) MergeMessagesImageBlock added in v1.26.0

func (t *MessagesRequestContentBlock) MergeMessagesImageBlock(v MessagesImageBlock) error

MergeMessagesImageBlock performs a merge with any union data inside the MessagesRequestContentBlock, using the provided MessagesImageBlock

func (*MessagesRequestContentBlock) MergeMessagesRedactedThinkingBlock added in v1.26.0

func (t *MessagesRequestContentBlock) MergeMessagesRedactedThinkingBlock(v MessagesRedactedThinkingBlock) error

MergeMessagesRedactedThinkingBlock performs a merge with any union data inside the MessagesRequestContentBlock, using the provided MessagesRedactedThinkingBlock

func (*MessagesRequestContentBlock) MergeMessagesTextBlock added in v1.26.0

func (t *MessagesRequestContentBlock) MergeMessagesTextBlock(v MessagesTextBlock) error

MergeMessagesTextBlock performs a merge with any union data inside the MessagesRequestContentBlock, using the provided MessagesTextBlock

func (*MessagesRequestContentBlock) MergeMessagesThinkingBlock added in v1.26.0

func (t *MessagesRequestContentBlock) MergeMessagesThinkingBlock(v MessagesThinkingBlock) error

MergeMessagesThinkingBlock performs a merge with any union data inside the MessagesRequestContentBlock, using the provided MessagesThinkingBlock

func (*MessagesRequestContentBlock) MergeMessagesToolResultBlock added in v1.26.0

func (t *MessagesRequestContentBlock) MergeMessagesToolResultBlock(v MessagesToolResultBlock) error

MergeMessagesToolResultBlock performs a merge with any union data inside the MessagesRequestContentBlock, using the provided MessagesToolResultBlock

func (*MessagesRequestContentBlock) MergeMessagesToolUseBlock added in v1.26.0

func (t *MessagesRequestContentBlock) MergeMessagesToolUseBlock(v MessagesToolUseBlock) error

MergeMessagesToolUseBlock performs a merge with any union data inside the MessagesRequestContentBlock, using the provided MessagesToolUseBlock

func (*MessagesRequestContentBlock) UnmarshalJSON added in v1.26.0

func (t *MessagesRequestContentBlock) UnmarshalJSON(b []byte) error

type MessagesResponse added in v1.26.0

type MessagesResponse struct {
	// Content The content blocks generated by the model.
	Content []MessagesResponseContentBlock `json:"content"`

	// ID Unique identifier for this message.
	ID string `json:"id"`

	// Model The model used to generate the message.
	Model string `json:"model"`

	// Role Always `assistant`.
	Role MessagesResponseRole `json:"role"`

	// StopReason The reason the model stopped generating.
	StopReason MessagesResponseStopReason `json:"stop_reason"`

	// StopSequence The stop sequence that caused the model to stop, if any.
	StopSequence *string `json:"stop_sequence,omitempty"`

	// Type Always `message`.
	Type MessagesResponseType `json:"type"`

	// Usage Token usage statistics for a Messages API response, including
	// cache metrics.
	Usage MessagesUsage `json:"usage"`
}

MessagesResponse A message response from the Anthropic-compatible Messages API.

type MessagesResponseContentBlock added in v1.26.0

type MessagesResponseContentBlock struct {
	// contains filtered or unexported fields
}

MessagesResponseContentBlock A content block within a Messages API response.

func (MessagesResponseContentBlock) AsMessagesRedactedThinkingBlock added in v1.26.0

func (t MessagesResponseContentBlock) AsMessagesRedactedThinkingBlock() (MessagesRedactedThinkingBlock, error)

AsMessagesRedactedThinkingBlock returns the union data inside the MessagesResponseContentBlock as a MessagesRedactedThinkingBlock

func (MessagesResponseContentBlock) AsMessagesTextBlock added in v1.26.0

func (t MessagesResponseContentBlock) AsMessagesTextBlock() (MessagesTextBlock, error)

AsMessagesTextBlock returns the union data inside the MessagesResponseContentBlock as a MessagesTextBlock

func (MessagesResponseContentBlock) AsMessagesThinkingBlock added in v1.26.0

func (t MessagesResponseContentBlock) AsMessagesThinkingBlock() (MessagesThinkingBlock, error)

AsMessagesThinkingBlock returns the union data inside the MessagesResponseContentBlock as a MessagesThinkingBlock

func (MessagesResponseContentBlock) AsMessagesToolUseBlock added in v1.26.0

func (t MessagesResponseContentBlock) AsMessagesToolUseBlock() (MessagesToolUseBlock, error)

AsMessagesToolUseBlock returns the union data inside the MessagesResponseContentBlock as a MessagesToolUseBlock

func (*MessagesResponseContentBlock) FromMessagesRedactedThinkingBlock added in v1.26.0

func (t *MessagesResponseContentBlock) FromMessagesRedactedThinkingBlock(v MessagesRedactedThinkingBlock) error

FromMessagesRedactedThinkingBlock overwrites any union data inside the MessagesResponseContentBlock as the provided MessagesRedactedThinkingBlock

func (*MessagesResponseContentBlock) FromMessagesTextBlock added in v1.26.0

func (t *MessagesResponseContentBlock) FromMessagesTextBlock(v MessagesTextBlock) error

FromMessagesTextBlock overwrites any union data inside the MessagesResponseContentBlock as the provided MessagesTextBlock

func (*MessagesResponseContentBlock) FromMessagesThinkingBlock added in v1.26.0

func (t *MessagesResponseContentBlock) FromMessagesThinkingBlock(v MessagesThinkingBlock) error

FromMessagesThinkingBlock overwrites any union data inside the MessagesResponseContentBlock as the provided MessagesThinkingBlock

func (*MessagesResponseContentBlock) FromMessagesToolUseBlock added in v1.26.0

func (t *MessagesResponseContentBlock) FromMessagesToolUseBlock(v MessagesToolUseBlock) error

FromMessagesToolUseBlock overwrites any union data inside the MessagesResponseContentBlock as the provided MessagesToolUseBlock

func (MessagesResponseContentBlock) MarshalJSON added in v1.26.0

func (t MessagesResponseContentBlock) MarshalJSON() ([]byte, error)

func (*MessagesResponseContentBlock) MergeMessagesRedactedThinkingBlock added in v1.26.0

func (t *MessagesResponseContentBlock) MergeMessagesRedactedThinkingBlock(v MessagesRedactedThinkingBlock) error

MergeMessagesRedactedThinkingBlock performs a merge with any union data inside the MessagesResponseContentBlock, using the provided MessagesRedactedThinkingBlock

func (*MessagesResponseContentBlock) MergeMessagesTextBlock added in v1.26.0

func (t *MessagesResponseContentBlock) MergeMessagesTextBlock(v MessagesTextBlock) error

MergeMessagesTextBlock performs a merge with any union data inside the MessagesResponseContentBlock, using the provided MessagesTextBlock

func (*MessagesResponseContentBlock) MergeMessagesThinkingBlock added in v1.26.0

func (t *MessagesResponseContentBlock) MergeMessagesThinkingBlock(v MessagesThinkingBlock) error

MergeMessagesThinkingBlock performs a merge with any union data inside the MessagesResponseContentBlock, using the provided MessagesThinkingBlock

func (*MessagesResponseContentBlock) MergeMessagesToolUseBlock added in v1.26.0

func (t *MessagesResponseContentBlock) MergeMessagesToolUseBlock(v MessagesToolUseBlock) error

MergeMessagesToolUseBlock performs a merge with any union data inside the MessagesResponseContentBlock, using the provided MessagesToolUseBlock

func (*MessagesResponseContentBlock) UnmarshalJSON added in v1.26.0

func (t *MessagesResponseContentBlock) UnmarshalJSON(b []byte) error

type MessagesResponseRole added in v1.26.0

type MessagesResponseRole string

MessagesResponseRole Always `assistant`.

const (
	MessagesResponseRoleAssistant MessagesResponseRole = "assistant"
)

Defines values for MessagesResponseRole.

func (MessagesResponseRole) Valid added in v1.26.0

func (e MessagesResponseRole) Valid() bool

Valid indicates whether the value is a known member of the MessagesResponseRole enum.

type MessagesResponseStopReason added in v1.26.0

type MessagesResponseStopReason string

MessagesResponseStopReason The reason the model stopped generating.

const (
	MessagesResponseStopReasonEndTurn      MessagesResponseStopReason = "end_turn"
	MessagesResponseStopReasonMaxTokens    MessagesResponseStopReason = "max_tokens"
	MessagesResponseStopReasonPauseTurn    MessagesResponseStopReason = "pause_turn"
	MessagesResponseStopReasonRefusal      MessagesResponseStopReason = "refusal"
	MessagesResponseStopReasonStopSequence MessagesResponseStopReason = "stop_sequence"
	MessagesResponseStopReasonToolUse      MessagesResponseStopReason = "tool_use"
)

Defines values for MessagesResponseStopReason.

func (MessagesResponseStopReason) Valid added in v1.26.0

func (e MessagesResponseStopReason) Valid() bool

Valid indicates whether the value is a known member of the MessagesResponseStopReason enum.

type MessagesResponseType added in v1.26.0

type MessagesResponseType string

MessagesResponseType Always `message`.

const (
	MessagesResponseTypeMessage MessagesResponseType = "message"
)

Defines values for MessagesResponseType.

func (MessagesResponseType) Valid added in v1.26.0

func (e MessagesResponseType) Valid() bool

Valid indicates whether the value is a known member of the MessagesResponseType enum.

type MessagesStreamEvent added in v1.26.0

type MessagesStreamEvent struct {
	// ContentBlock Present in `content_block_start` events. Contains the content
	// block.
	ContentBlock *MessagesResponseContentBlock `json:"content_block,omitempty"`

	// Delta Present in `content_block_delta` and `message_delta` events.
	// Contains the incremental update.
	Delta *struct {
		// PartialJSON The incremental JSON string of the tool input
		// (for `input_json_delta`).
		PartialJSON *string `json:"partial_json,omitempty"`

		// Signature The thinking signature (for `signature_delta`).
		Signature *string `json:"signature,omitempty"`

		// StopReason The stop reason (for `message_delta`).
		StopReason *string `json:"stop_reason,omitempty"`

		// StopSequence The stop sequence (for `message_delta`).
		StopSequence *string `json:"stop_sequence,omitempty"`

		// Text The incremental text (for `text_delta`).
		Text *string `json:"text,omitempty"`

		// Thinking The incremental thinking content (for `thinking_delta`).
		Thinking *string `json:"thinking,omitempty"`

		// Type The type of delta. For text deltas this is `text_delta`,
		// for streamed tool inputs this is `input_json_delta`, for
		// thinking deltas this is `thinking_delta`, for thinking
		// signatures this is `signature_delta`.
		Type *string `json:"type,omitempty"`
	} `json:"delta,omitempty"`

	// Error Present in `error` events. Contains the error details.
	Error *MessagesError `json:"error,omitempty"`

	// Index Present in `content_block_*` events. The index of the content
	// block.
	Index *int `json:"index,omitempty"`

	// Message Present in `message_start` events. Contains the initial message.
	Message *MessagesResponse `json:"message,omitempty"`

	// Type The type of the streamed event.
	Type MessagesStreamEventType `json:"type"`

	// Usage Present in `message_delta` events as a sibling of `delta`.
	// Contains cumulative usage for the message.
	Usage *MessagesUsage `json:"usage,omitempty"`
}

MessagesStreamEvent A server-sent event emitted while streaming a Messages API response. The Anthropic Messages API emits a sequence of typed events (`message_start`, `content_block_start`, `content_block_delta`, `content_block_stop`, `message_delta`, `message_stop`, `ping`).

type MessagesStreamEventType added in v1.26.0

type MessagesStreamEventType string

MessagesStreamEventType The type of the streamed event.

const (
	MessagesStreamEventTypeContentBlockDelta MessagesStreamEventType = "content_block_delta"
	MessagesStreamEventTypeContentBlockStart MessagesStreamEventType = "content_block_start"
	MessagesStreamEventTypeContentBlockStop  MessagesStreamEventType = "content_block_stop"
	MessagesStreamEventTypeError             MessagesStreamEventType = "error"
	MessagesStreamEventTypeMessageDelta      MessagesStreamEventType = "message_delta"
	MessagesStreamEventTypeMessageStart      MessagesStreamEventType = "message_start"
	MessagesStreamEventTypeMessageStop       MessagesStreamEventType = "message_stop"
	MessagesStreamEventTypePing              MessagesStreamEventType = "ping"
)

Defines values for MessagesStreamEventType.

func (MessagesStreamEventType) Valid added in v1.26.0

func (e MessagesStreamEventType) Valid() bool

Valid indicates whether the value is a known member of the MessagesStreamEventType enum.

type MessagesTextBlock added in v1.26.0

type MessagesTextBlock struct {
	// CacheControl Cache control settings for prompt caching. Currently only
	// `ephemeral` caching is supported.
	CacheControl *CacheControl `json:"cache_control,omitempty"`

	// Text The text content.
	Text string `json:"text"`

	// Type Content type identifier. Always `text`.
	Type MessagesTextBlockType `json:"type"`
}

MessagesTextBlock A text content block in a Messages API request or response.

type MessagesTextBlockType added in v1.26.0

type MessagesTextBlockType string

MessagesTextBlockType Content type identifier. Always `text`.

const (
	MessagesTextBlockTypeText MessagesTextBlockType = "text"
)

Defines values for MessagesTextBlockType.

func (MessagesTextBlockType) Valid added in v1.26.0

func (e MessagesTextBlockType) Valid() bool

Valid indicates whether the value is a known member of the MessagesTextBlockType enum.

type MessagesThinkingBlock added in v1.26.0

type MessagesThinkingBlock struct {
	// Signature The signature for verifying the thinking content. Must be
	// passed back when continuing a conversation with extended thinking.
	Signature string `json:"signature"`

	// Thinking The thinking content.
	Thinking string `json:"thinking"`

	// Type Content type identifier. Always `thinking`.
	Type MessagesThinkingBlockType `json:"type"`
}

MessagesThinkingBlock A thinking content block in a Messages API request or response.

type MessagesThinkingBlockType added in v1.26.0

type MessagesThinkingBlockType string

MessagesThinkingBlockType Content type identifier. Always `thinking`.

const (
	Thinking MessagesThinkingBlockType = "thinking"
)

Defines values for MessagesThinkingBlockType.

func (MessagesThinkingBlockType) Valid added in v1.26.0

func (e MessagesThinkingBlockType) Valid() bool

Valid indicates whether the value is a known member of the MessagesThinkingBlockType enum.

type MessagesTool added in v1.26.0

type MessagesTool struct {
	// CacheControl Cache control settings for prompt caching. Currently only
	// `ephemeral` caching is supported.
	CacheControl *CacheControl `json:"cache_control,omitempty"`

	// Description A description of what the tool does.
	Description *string `json:"description,omitempty"`

	// InputSchema The parameters the functions accepts, described as a JSON Schema object. See the [guide](/docs/guides/function-calling) for examples, and the [JSON Schema reference](https://json-schema.org/understanding-json-schema/) for documentation about the format.
	// Omitting `parameters` defines a function with an empty parameter list.
	InputSchema FunctionParameters `json:"input_schema"`

	// Name The name of the tool.
	Name string `json:"name"`
}

MessagesTool A tool definition in the Messages API format. Uses the same function tool shape as the Responses API but with an optional `cache_control` field for prompt caching.

type MessagesToolChoice added in v1.26.0

type MessagesToolChoice struct {
	// contains filtered or unexported fields
}

MessagesToolChoice Controls which (if any) tool is called by the model. `auto` means the model can decide, `any` means the model must use a tool, and `tool` forces a specific tool.

func (MessagesToolChoice) AsMessagesToolChoice0 added in v1.26.0

func (t MessagesToolChoice) AsMessagesToolChoice0() (MessagesToolChoice0, error)

AsMessagesToolChoice0 returns the union data inside the MessagesToolChoice as a MessagesToolChoice0

func (MessagesToolChoice) AsMessagesToolChoice1 added in v1.26.0

func (t MessagesToolChoice) AsMessagesToolChoice1() (MessagesToolChoice1, error)

AsMessagesToolChoice1 returns the union data inside the MessagesToolChoice as a MessagesToolChoice1

func (*MessagesToolChoice) FromMessagesToolChoice0 added in v1.26.0

func (t *MessagesToolChoice) FromMessagesToolChoice0(v MessagesToolChoice0) error

FromMessagesToolChoice0 overwrites any union data inside the MessagesToolChoice as the provided MessagesToolChoice0

func (*MessagesToolChoice) FromMessagesToolChoice1 added in v1.26.0

func (t *MessagesToolChoice) FromMessagesToolChoice1(v MessagesToolChoice1) error

FromMessagesToolChoice1 overwrites any union data inside the MessagesToolChoice as the provided MessagesToolChoice1

func (MessagesToolChoice) MarshalJSON added in v1.26.0

func (t MessagesToolChoice) MarshalJSON() ([]byte, error)

func (*MessagesToolChoice) MergeMessagesToolChoice0 added in v1.26.0

func (t *MessagesToolChoice) MergeMessagesToolChoice0(v MessagesToolChoice0) error

MergeMessagesToolChoice0 performs a merge with any union data inside the MessagesToolChoice, using the provided MessagesToolChoice0

func (*MessagesToolChoice) MergeMessagesToolChoice1 added in v1.26.0

func (t *MessagesToolChoice) MergeMessagesToolChoice1(v MessagesToolChoice1) error

MergeMessagesToolChoice1 performs a merge with any union data inside the MessagesToolChoice, using the provided MessagesToolChoice1

func (*MessagesToolChoice) UnmarshalJSON added in v1.26.0

func (t *MessagesToolChoice) UnmarshalJSON(b []byte) error

type MessagesToolChoice0 added in v1.26.0

type MessagesToolChoice0 string

MessagesToolChoice0 The tool choice mode.

const (
	MessagesToolChoice0Any  MessagesToolChoice0 = "any"
	MessagesToolChoice0Auto MessagesToolChoice0 = "auto"
)

Defines values for MessagesToolChoice0.

func (MessagesToolChoice0) Valid added in v1.26.0

func (e MessagesToolChoice0) Valid() bool

Valid indicates whether the value is a known member of the MessagesToolChoice0 enum.

type MessagesToolChoice1 added in v1.26.0

type MessagesToolChoice1 struct {
	// Name The name of the tool to use.
	Name string `json:"name"`

	// Type Always `tool`.
	Type MessagesToolChoice1Type `json:"type"`
}

MessagesToolChoice1 Forces the model to use a specific tool.

type MessagesToolChoice1Type added in v1.26.0

type MessagesToolChoice1Type string

MessagesToolChoice1Type Always `tool`.

const (
	MessagesToolChoiceTypeTool MessagesToolChoice1Type = "tool"
)

Defines values for MessagesToolChoice1Type.

func (MessagesToolChoice1Type) Valid added in v1.26.0

func (e MessagesToolChoice1Type) Valid() bool

Valid indicates whether the value is a known member of the MessagesToolChoice1Type enum.

type MessagesToolResultBlock added in v1.26.0

type MessagesToolResultBlock struct {
	// CacheControl Cache control settings for prompt caching. Currently only
	// `ephemeral` caching is supported.
	CacheControl *CacheControl `json:"cache_control,omitempty"`

	// Content The result content. Can be a string or an array of content blocks.
	Content *MessagesToolResultBlock_Content `json:"content,omitempty"`

	// IsError Whether the tool execution resulted in an error.
	IsError *bool `json:"is_error,omitempty"`

	// ToolUseID The ID of the tool use this result is for.
	ToolUseID string `json:"tool_use_id"`

	// Type Content type identifier. Always `tool_result`.
	Type MessagesToolResultBlockType `json:"type"`
}

MessagesToolResultBlock A tool result content block in a Messages API request.

type MessagesToolResultBlockContent0 added in v1.26.0

type MessagesToolResultBlockContent0 = string

MessagesToolResultBlockContent0 Text result content.

type MessagesToolResultBlockContent1 added in v1.26.0

type MessagesToolResultBlockContent1 = []MessagesTextBlock

MessagesToolResultBlockContent1 defines model for MessagesToolResultBlock.Content.1.

type MessagesToolResultBlockType added in v1.26.0

type MessagesToolResultBlockType string

MessagesToolResultBlockType Content type identifier. Always `tool_result`.

const (
	ToolResult MessagesToolResultBlockType = "tool_result"
)

Defines values for MessagesToolResultBlockType.

func (MessagesToolResultBlockType) Valid added in v1.26.0

Valid indicates whether the value is a known member of the MessagesToolResultBlockType enum.

type MessagesToolResultBlock_Content added in v1.26.0

type MessagesToolResultBlock_Content struct {
	// contains filtered or unexported fields
}

MessagesToolResultBlock_Content The result content. Can be a string or an array of content blocks.

func (MessagesToolResultBlock_Content) AsMessagesToolResultBlockContent0 added in v1.26.0

func (t MessagesToolResultBlock_Content) AsMessagesToolResultBlockContent0() (MessagesToolResultBlockContent0, error)

AsMessagesToolResultBlockContent0 returns the union data inside the MessagesToolResultBlock_Content as a MessagesToolResultBlockContent0

func (MessagesToolResultBlock_Content) AsMessagesToolResultBlockContent1 added in v1.26.0

func (t MessagesToolResultBlock_Content) AsMessagesToolResultBlockContent1() (MessagesToolResultBlockContent1, error)

AsMessagesToolResultBlockContent1 returns the union data inside the MessagesToolResultBlock_Content as a MessagesToolResultBlockContent1

func (*MessagesToolResultBlock_Content) FromMessagesToolResultBlockContent0 added in v1.26.0

func (t *MessagesToolResultBlock_Content) FromMessagesToolResultBlockContent0(v MessagesToolResultBlockContent0) error

FromMessagesToolResultBlockContent0 overwrites any union data inside the MessagesToolResultBlock_Content as the provided MessagesToolResultBlockContent0

func (*MessagesToolResultBlock_Content) FromMessagesToolResultBlockContent1 added in v1.26.0

func (t *MessagesToolResultBlock_Content) FromMessagesToolResultBlockContent1(v MessagesToolResultBlockContent1) error

FromMessagesToolResultBlockContent1 overwrites any union data inside the MessagesToolResultBlock_Content as the provided MessagesToolResultBlockContent1

func (MessagesToolResultBlock_Content) MarshalJSON added in v1.26.0

func (t MessagesToolResultBlock_Content) MarshalJSON() ([]byte, error)

func (*MessagesToolResultBlock_Content) MergeMessagesToolResultBlockContent0 added in v1.26.0

func (t *MessagesToolResultBlock_Content) MergeMessagesToolResultBlockContent0(v MessagesToolResultBlockContent0) error

MergeMessagesToolResultBlockContent0 performs a merge with any union data inside the MessagesToolResultBlock_Content, using the provided MessagesToolResultBlockContent0

func (*MessagesToolResultBlock_Content) MergeMessagesToolResultBlockContent1 added in v1.26.0

func (t *MessagesToolResultBlock_Content) MergeMessagesToolResultBlockContent1(v MessagesToolResultBlockContent1) error

MergeMessagesToolResultBlockContent1 performs a merge with any union data inside the MessagesToolResultBlock_Content, using the provided MessagesToolResultBlockContent1

func (*MessagesToolResultBlock_Content) UnmarshalJSON added in v1.26.0

func (t *MessagesToolResultBlock_Content) UnmarshalJSON(b []byte) error

type MessagesToolUseBlock added in v1.26.0

type MessagesToolUseBlock struct {
	// ID The unique identifier for this tool use block.
	ID string `json:"id"`

	// Input The input parameters for the tool.
	Input map[string]any `json:"input"`

	// Name The name of the tool being called.
	Name string `json:"name"`

	// Type Content type identifier. Always `tool_use`.
	Type MessagesToolUseBlockType `json:"type"`
}

MessagesToolUseBlock A tool use content block in a Messages API request or response.

type MessagesToolUseBlockType added in v1.26.0

type MessagesToolUseBlockType string

MessagesToolUseBlockType Content type identifier. Always `tool_use`.

const (
	MessagesToolUseBlockTypeToolUse MessagesToolUseBlockType = "tool_use"
)

Defines values for MessagesToolUseBlockType.

func (MessagesToolUseBlockType) Valid added in v1.26.0

func (e MessagesToolUseBlockType) Valid() bool

Valid indicates whether the value is a known member of the MessagesToolUseBlockType enum.

type MessagesUsage added in v1.26.0

type MessagesUsage struct {
	// CacheCreationInputTokens The number of tokens used for cache creation.
	CacheCreationInputTokens *int64 `json:"cache_creation_input_tokens,omitempty"`

	// CacheReadInputTokens The number of tokens read from the cache.
	CacheReadInputTokens *int64 `json:"cache_read_input_tokens,omitempty"`

	// InputTokens The number of input tokens.
	InputTokens int64 `json:"input_tokens"`

	// OutputTokens The number of output tokens.
	OutputTokens int64 `json:"output_tokens"`
}

MessagesUsage Token usage statistics for a Messages API response, including cache metrics.

type MiddlewareOptions added in v1.9.0

type MiddlewareOptions struct {
	// SkipMCP bypasses MCP middleware processing
	SkipMCP bool
	// DirectProvider routes directly to provider without middleware
	DirectProvider bool
}

MiddlewareOptions represents options for controlling middleware behavior

type Modality added in v1.35.0

type Modality string

Modality A single input or output modality

const (
	ModalityAudio Modality = "audio"
	ModalityImage Modality = "image"
	ModalityText  Modality = "text"
	ModalityVideo Modality = "video"
)

Defines values for Modality.

func (Modality) Valid added in v1.35.0

func (e Modality) Valid() bool

Valid indicates whether the value is a known member of the Modality enum.

type Model

type Model struct {
	// ContextWindow Context window information for the model (included when `include=context_window`)
	ContextWindow *ContextWindow `json:"context_window,omitempty"`
	Created       int64          `json:"created"`
	ID            string         `json:"id"`

	// Modalities The input and output modalities of the model (included when `include=modalities`)
	Modalities *ModelModalities `json:"modalities,omitempty"`
	Object     string           `json:"object"`
	OwnedBy    string           `json:"owned_by"`

	// Pricing Pricing information for the model (included when `include=pricing`)
	Pricing  *Pricing `json:"pricing,omitempty"`
	ServedBy Provider `json:"served_by"`
}

Model Common model information

type ModelModalities added in v1.34.0

type ModelModalities struct {
	Input  []Modality `json:"input"`
	Output []Modality `json:"output"`
}

ModelModalities The input and output modalities of a model, mirroring the models.dev dataset shape. Vision models accept `image` in `input`; image-generation models list `image` in `output` — when `output` carries `image` but not `text`, the model only generates images and cannot chat.

type Pricing added in v1.24.0

type Pricing struct {
	// CacheReadPerToken Price per cached input token read
	CacheReadPerToken *string `json:"cache_read_per_token,omitempty"`

	// CacheWritePerToken Price per cached input token write
	CacheWritePerToken *string `json:"cache_write_per_token,omitempty"`

	// Currency Currency code for the pricing (e.g. USD)
	Currency string `json:"currency"`

	// InputPerToken Price per input token
	InputPerToken string `json:"input_per_token"`

	// OutputPerToken Price per output token
	OutputPerToken string `json:"output_per_token"`

	// Source Source of the pricing information
	Source PricingSource `json:"source"`

	// Subscription Model has no per-token price but is gated behind a paid subscription
	Subscription *bool `json:"subscription,omitempty"`

	// UpdatedAt Timestamp when the pricing was last updated
	UpdatedAt time.Time `json:"updated_at"`
}

Pricing Pricing information for a model

type PricingSource added in v1.25.0

type PricingSource string

PricingSource Source of the pricing information

const (
	PricingSourceCommunity PricingSource = "community"
	PricingSourceProvider  PricingSource = "provider"
)

Defines values for PricingSource.

func (PricingSource) Valid added in v1.25.0

func (e PricingSource) Valid() bool

Valid indicates whether the value is a known member of the PricingSource enum.

type Provider

type Provider string

Provider defines model for Provider.

const (
	Anthropic   Provider = "anthropic"
	Cloudflare  Provider = "cloudflare"
	Cohere      Provider = "cohere"
	Deepseek    Provider = "deepseek"
	Google      Provider = "google"
	Groq        Provider = "groq"
	Llamacpp    Provider = "llamacpp"
	Minimax     Provider = "minimax"
	Mistral     Provider = "mistral"
	Moonshot    Provider = "moonshot"
	Nvidia      Provider = "nvidia"
	Ollama      Provider = "ollama"
	OllamaCloud Provider = "ollama_cloud"
	Openai      Provider = "openai"
	Zai         Provider = "zai"
)

Defines values for Provider.

func (Provider) Valid added in v1.16.0

func (e Provider) Valid() bool

Valid indicates whether the value is a known member of the Provider enum.

type ProviderRequest added in v1.5.0

type ProviderRequest struct {
	Messages *[]struct {
		Content *string `json:"content,omitempty"`
		Role    *string `json:"role,omitempty"`
	} `json:"messages,omitempty"`
	Model       *string  `json:"model,omitempty"`
	Temperature *float32 `json:"temperature,omitempty"`
}

ProviderRequest defines model for ProviderRequest.

type ProviderResponse added in v1.5.0

type ProviderResponse = ProviderSpecificResponse

ProviderResponse Provider-specific response format. Examples:

OpenAI GET /v1/models?provider=openai response: ```json

{
  "provider": "openai",
  "object": "list",
  "data": [
    {
      "id": "gpt-4",
      "object": "model",
      "created": 1687882410,
      "owned_by": "openai",
      "served_by": "openai"
    }
  ]
}

```

Anthropic GET /v1/models?provider=anthropic response: ```json

{
  "provider": "anthropic",
  "object": "list",
  "data": [
    {
      "id": "gpt-4",
      "object": "model",
      "created": 1687882410,
      "owned_by": "openai",
      "served_by": "openai"
    }
  ]
}

```

type ProviderSpecificResponse added in v1.5.0

type ProviderSpecificResponse = map[string]any

ProviderSpecificResponse Provider-specific response format. Examples:

OpenAI GET /v1/models?provider=openai response: ```json

{
  "provider": "openai",
  "object": "list",
  "data": [
    {
      "id": "gpt-4",
      "object": "model",
      "created": 1687882410,
      "owned_by": "openai",
      "served_by": "openai"
    }
  ]
}

```

Anthropic GET /v1/models?provider=anthropic response: ```json

{
  "provider": "anthropic",
  "object": "list",
  "data": [
    {
      "id": "gpt-4",
      "object": "model",
      "created": 1687882410,
      "owned_by": "openai",
      "served_by": "openai"
    }
  ]
}

```

type ProxyPatchJSONBody added in v1.5.0

type ProxyPatchJSONBody struct {
	Messages *[]struct {
		Content *string `json:"content,omitempty"`
		Role    *string `json:"role,omitempty"`
	} `json:"messages,omitempty"`
	Model       *string  `json:"model,omitempty"`
	Temperature *float32 `json:"temperature,omitempty"`
}

ProxyPatchJSONBody defines parameters for ProxyPatch.

type ProxyPatchJSONRequestBody added in v1.5.0

type ProxyPatchJSONRequestBody ProxyPatchJSONBody

ProxyPatchJSONRequestBody defines body for ProxyPatch for application/json ContentType.

type ProxyPostJSONBody added in v1.5.0

type ProxyPostJSONBody struct {
	Messages *[]struct {
		Content *string `json:"content,omitempty"`
		Role    *string `json:"role,omitempty"`
	} `json:"messages,omitempty"`
	Model       *string  `json:"model,omitempty"`
	Temperature *float32 `json:"temperature,omitempty"`
}

ProxyPostJSONBody defines parameters for ProxyPost.

type ProxyPostJSONRequestBody added in v1.5.0

type ProxyPostJSONRequestBody ProxyPostJSONBody

ProxyPostJSONRequestBody defines body for ProxyPost for application/json ContentType.

type ProxyPutJSONBody added in v1.5.0

type ProxyPutJSONBody struct {
	Messages *[]struct {
		Content *string `json:"content,omitempty"`
		Role    *string `json:"role,omitempty"`
	} `json:"messages,omitempty"`
	Model       *string  `json:"model,omitempty"`
	Temperature *float32 `json:"temperature,omitempty"`
}

ProxyPutJSONBody defines parameters for ProxyPut.

type ProxyPutJSONRequestBody added in v1.5.0

type ProxyPutJSONRequestBody ProxyPutJSONBody

ProxyPutJSONRequestBody defines body for ProxyPut for application/json ContentType.

type PushMetricsJSONBody added in v1.19.0

type PushMetricsJSONBody = map[string]any

PushMetricsJSONBody defines parameters for PushMetrics.

type PushMetricsJSONRequestBody added in v1.19.0

type PushMetricsJSONRequestBody = PushMetricsJSONBody

PushMetricsJSONRequestBody defines body for PushMetrics for application/json ContentType.

type Response added in v1.20.0

type Response struct {
	// CreatedAt Unix timestamp (in seconds) of when the response was created.
	CreatedAt int64 `json:"created_at"`

	// Error An error object returned when the model fails to generate a response.
	Error *ResponseError `json:"error,omitempty"`

	// ID Unique identifier for this response.
	ID string `json:"id"`

	// IncompleteDetails Details about why the response is incomplete.
	IncompleteDetails *ResponseIncompleteDetails `json:"incomplete_details,omitempty"`

	// Instructions The system/developer message used to generate the response.
	Instructions *string `json:"instructions,omitempty"`

	// MaxOutputTokens An upper bound for the number of generated tokens.
	MaxOutputTokens *int               `json:"max_output_tokens,omitempty"`
	Metadata        *map[string]string `json:"metadata,omitempty"`

	// Model The model used to generate the response.
	Model string `json:"model"`

	// Object The object type, which is always `response`.
	Object string `json:"object"`

	// Output An array of content items generated by the model.
	Output []ResponseOutputItem `json:"output"`

	// PreviousResponseID The unique ID of the previous response, if any.
	PreviousResponseID *string `json:"previous_response_id,omitempty"`

	// Reasoning Configuration options for reasoning models.
	Reasoning *ResponseReasoning `json:"reasoning,omitempty"`

	// Status The status of the response generation.
	Status      ResponseStatus `json:"status"`
	Temperature *float32       `json:"temperature,omitempty"`

	// Text Configuration options for a text response from the model. Can be plain text or structured JSON data.
	Text *ResponseTextConfig `json:"text,omitempty"`

	// ToolChoice How the model should select which tool (or tools) to use. Either a mode string (`none`, `auto`, `required`) or an object forcing a specific tool.
	ToolChoice *ResponseToolChoice `json:"tool_choice,omitempty"`
	Tools      *[]ResponseTool     `json:"tools,omitempty"`
	TopP       *float32            `json:"top_p,omitempty"`

	// Usage Token usage details for the response.
	Usage *ResponseUsage `json:"usage,omitempty"`
}

Response Represents a model response returned by the Responses API.

type ResponseError added in v1.4.0

type ResponseError struct {
	// Code The error code for the response.
	Code string `json:"code"`

	// Message A human-readable description of the error.
	Message string `json:"message"`
}

ResponseError An error object returned when the model fails to generate a response.

type ResponseFormatJSONObject added in v1.18.0

type ResponseFormatJSONObject struct {
	// Type The type of response format being defined. Always `json_object`.
	Type ResponseFormatJSONObjectType `json:"type"`
}

ResponseFormatJSONObject JSON object response format. An older method of generating JSON responses. Using `json_schema` is recommended for models that support it. Note that the model will not generate JSON without a system or user message instructing it to do so.

type ResponseFormatJSONObjectType added in v1.18.0

type ResponseFormatJSONObjectType string

ResponseFormatJSONObjectType The type of response format being defined. Always `json_object`.

const (
	JSONObject ResponseFormatJSONObjectType = "json_object"
)

Defines values for ResponseFormatJSONObjectType.

func (ResponseFormatJSONObjectType) Valid added in v1.18.0

Valid indicates whether the value is a known member of the ResponseFormatJSONObjectType enum.

type ResponseFormatJSONSchema added in v1.18.0

type ResponseFormatJSONSchema struct {
	// JSONSchema Structured Outputs configuration options, including a JSON Schema.
	JSONSchema struct {
		// Description A description of what the response format is for, used by the model to determine how to respond in the format.
		Description *string `json:"description,omitempty"`

		// Name The name of the response format. Must be a-z, A-Z, 0-9, or contain underscores and dashes, with a maximum length of 64.
		Name string `json:"name"`

		// Schema The schema for the response format, described as a JSON Schema object.
		Schema *ResponseFormatJSONSchemaSchema `json:"schema,omitempty"`

		// Strict Whether to enable strict schema adherence when generating the output. If set to true, the model will always follow the exact schema defined in the `schema` field. Only a subset of JSON Schema is supported when `strict` is `true`.
		Strict *bool `json:"strict,omitempty"`
	} `json:"json_schema"`

	// Type The type of response format being defined. Always `json_schema`.
	Type ResponseFormatJSONSchemaType `json:"type"`
}

ResponseFormatJSONSchema JSON Schema response format. Used to generate structured JSON responses.

type ResponseFormatJSONSchemaSchema added in v1.18.0

type ResponseFormatJSONSchemaSchema map[string]any

ResponseFormatJSONSchemaSchema The schema for the response format, described as a JSON Schema object.

type ResponseFormatJSONSchemaType added in v1.18.0

type ResponseFormatJSONSchemaType string

ResponseFormatJSONSchemaType The type of response format being defined. Always `json_schema`.

const (
	JSONSchema ResponseFormatJSONSchemaType = "json_schema"
)

Defines values for ResponseFormatJSONSchemaType.

func (ResponseFormatJSONSchemaType) Valid added in v1.18.0

Valid indicates whether the value is a known member of the ResponseFormatJSONSchemaType enum.

type ResponseFormatText added in v1.18.0

type ResponseFormatText struct {
	// Type The type of response format being defined. Always `text`.
	Type ResponseFormatTextType `json:"type"`
}

ResponseFormatText Default response format. Used to generate text responses.

type ResponseFormatTextType added in v1.18.0

type ResponseFormatTextType string

ResponseFormatTextType The type of response format being defined. Always `text`.

const (
	ResponseFormatTextTypeText ResponseFormatTextType = "text"
)

Defines values for ResponseFormatTextType.

func (ResponseFormatTextType) Valid added in v1.18.0

func (e ResponseFormatTextType) Valid() bool

Valid indicates whether the value is a known member of the ResponseFormatTextType enum.

type ResponseFunctionToolCall added in v1.20.0

type ResponseFunctionToolCall struct {
	// Arguments A JSON string of the arguments to pass to the function.
	Arguments string `json:"arguments"`

	// CallID The unique ID of the function tool call generated by the model, used to associate the call with its output.
	CallID string `json:"call_id"`

	// ID The unique ID of the function tool call.
	ID *string `json:"id,omitempty"`

	// Name The name of the function to run.
	Name string `json:"name"`

	// Status The status of the function tool call.
	Status *ResponseFunctionToolCallStatus `json:"status,omitempty"`

	// Type The type of the output item. Always `function_call`.
	Type ResponseFunctionToolCallType `json:"type"`
}

ResponseFunctionToolCall A tool call to a function generated by the model.

type ResponseFunctionToolCallStatus added in v1.20.0

type ResponseFunctionToolCallStatus string

ResponseFunctionToolCallStatus The status of the function tool call.

const (
	ResponseFunctionToolCallStatusCompleted  ResponseFunctionToolCallStatus = "completed"
	ResponseFunctionToolCallStatusInProgress ResponseFunctionToolCallStatus = "in_progress"
	ResponseFunctionToolCallStatusIncomplete ResponseFunctionToolCallStatus = "incomplete"
)

Defines values for ResponseFunctionToolCallStatus.

func (ResponseFunctionToolCallStatus) Valid added in v1.20.0

Valid indicates whether the value is a known member of the ResponseFunctionToolCallStatus enum.

type ResponseFunctionToolCallType added in v1.20.0

type ResponseFunctionToolCallType string

ResponseFunctionToolCallType The type of the output item. Always `function_call`.

const (
	ResponseFunctionToolCallTypeFunctionCall ResponseFunctionToolCallType = "function_call"
)

Defines values for ResponseFunctionToolCallType.

func (ResponseFunctionToolCallType) Valid added in v1.20.0

Valid indicates whether the value is a known member of the ResponseFunctionToolCallType enum.

type ResponseIncompleteDetails added in v1.20.0

type ResponseIncompleteDetails struct {
	// Reason The reason why the response is incomplete.
	Reason *string `json:"reason,omitempty"`
}

ResponseIncompleteDetails Details about why the response is incomplete.

type ResponseInput added in v1.20.0

type ResponseInput struct {
	// contains filtered or unexported fields
}

ResponseInput Text, image, or file inputs to the model. Either a single text prompt or a list of input items representing a (possibly batched) conversation.

func (ResponseInput) AsResponseInput0 added in v1.20.0

func (t ResponseInput) AsResponseInput0() (ResponseInput0, error)

AsResponseInput0 returns the union data inside the ResponseInput as a ResponseInput0

func (ResponseInput) AsResponseInput1 added in v1.20.0

func (t ResponseInput) AsResponseInput1() (ResponseInput1, error)

AsResponseInput1 returns the union data inside the ResponseInput as a ResponseInput1

func (*ResponseInput) FromResponseInput0 added in v1.20.0

func (t *ResponseInput) FromResponseInput0(v ResponseInput0) error

FromResponseInput0 overwrites any union data inside the ResponseInput as the provided ResponseInput0

func (*ResponseInput) FromResponseInput1 added in v1.20.0

func (t *ResponseInput) FromResponseInput1(v ResponseInput1) error

FromResponseInput1 overwrites any union data inside the ResponseInput as the provided ResponseInput1

func (ResponseInput) MarshalJSON added in v1.20.0

func (t ResponseInput) MarshalJSON() ([]byte, error)

func (*ResponseInput) MergeResponseInput0 added in v1.20.0

func (t *ResponseInput) MergeResponseInput0(v ResponseInput0) error

MergeResponseInput0 performs a merge with any union data inside the ResponseInput, using the provided ResponseInput0

func (*ResponseInput) MergeResponseInput1 added in v1.20.0

func (t *ResponseInput) MergeResponseInput1(v ResponseInput1) error

MergeResponseInput1 performs a merge with any union data inside the ResponseInput, using the provided ResponseInput1

func (*ResponseInput) UnmarshalJSON added in v1.20.0

func (t *ResponseInput) UnmarshalJSON(b []byte) error

type ResponseInput0 added in v1.20.0

type ResponseInput0 = string

ResponseInput0 A text input to the model, equivalent to a user message.

type ResponseInput1 added in v1.20.0

type ResponseInput1 = []ResponseInputItem

ResponseInput1 A list of input items.

type ResponseInputContentPart added in v1.20.0

type ResponseInputContentPart struct {
	// contains filtered or unexported fields
}

ResponseInputContentPart A content part within an input message.

func (ResponseInputContentPart) AsResponseInputImage added in v1.20.0

func (t ResponseInputContentPart) AsResponseInputImage() (ResponseInputImage, error)

AsResponseInputImage returns the union data inside the ResponseInputContentPart as a ResponseInputImage

func (ResponseInputContentPart) AsResponseInputText added in v1.20.0

func (t ResponseInputContentPart) AsResponseInputText() (ResponseInputText, error)

AsResponseInputText returns the union data inside the ResponseInputContentPart as a ResponseInputText

func (*ResponseInputContentPart) FromResponseInputImage added in v1.20.0

func (t *ResponseInputContentPart) FromResponseInputImage(v ResponseInputImage) error

FromResponseInputImage overwrites any union data inside the ResponseInputContentPart as the provided ResponseInputImage

func (*ResponseInputContentPart) FromResponseInputText added in v1.20.0

func (t *ResponseInputContentPart) FromResponseInputText(v ResponseInputText) error

FromResponseInputText overwrites any union data inside the ResponseInputContentPart as the provided ResponseInputText

func (ResponseInputContentPart) MarshalJSON added in v1.20.0

func (t ResponseInputContentPart) MarshalJSON() ([]byte, error)

func (*ResponseInputContentPart) MergeResponseInputImage added in v1.20.0

func (t *ResponseInputContentPart) MergeResponseInputImage(v ResponseInputImage) error

MergeResponseInputImage performs a merge with any union data inside the ResponseInputContentPart, using the provided ResponseInputImage

func (*ResponseInputContentPart) MergeResponseInputText added in v1.20.0

func (t *ResponseInputContentPart) MergeResponseInputText(v ResponseInputText) error

MergeResponseInputText performs a merge with any union data inside the ResponseInputContentPart, using the provided ResponseInputText

func (*ResponseInputContentPart) UnmarshalJSON added in v1.20.0

func (t *ResponseInputContentPart) UnmarshalJSON(b []byte) error

type ResponseInputImage added in v1.20.0

type ResponseInputImage struct {
	// Detail The detail level of the image to send to the model.
	Detail *ResponseInputImageDetail `json:"detail,omitempty"`

	// ImageURL The URL of the image (data URLs supported).
	ImageURL *string `json:"image_url,omitempty"`

	// Type The type of the input item. Always `input_image`.
	Type ResponseInputImageType `json:"type"`
}

ResponseInputImage An image input to the model.

type ResponseInputImageDetail added in v1.20.0

type ResponseInputImageDetail string

ResponseInputImageDetail The detail level of the image to send to the model.

const (
	ResponseInputImageDetailAuto ResponseInputImageDetail = "auto"
	ResponseInputImageDetailHigh ResponseInputImageDetail = "high"
	ResponseInputImageDetailLow  ResponseInputImageDetail = "low"
)

Defines values for ResponseInputImageDetail.

func (ResponseInputImageDetail) Valid added in v1.20.0

func (e ResponseInputImageDetail) Valid() bool

Valid indicates whether the value is a known member of the ResponseInputImageDetail enum.

type ResponseInputImageType added in v1.20.0

type ResponseInputImageType string

ResponseInputImageType The type of the input item. Always `input_image`.

const (
	InputImage ResponseInputImageType = "input_image"
)

Defines values for ResponseInputImageType.

func (ResponseInputImageType) Valid added in v1.20.0

func (e ResponseInputImageType) Valid() bool

Valid indicates whether the value is a known member of the ResponseInputImageType enum.

type ResponseInputItem added in v1.20.0

type ResponseInputItem struct {
	// Content Text or multimodal content for an input message. Either a string or a list of content parts.
	Content ResponseInputMessageContent `json:"content"`

	// Role The role of the message input.
	Role ResponseRole `json:"role"`

	// Type The type of the input item. Defaults to `message`.
	Type *string `json:"type,omitempty"`
}

ResponseInputItem A single input item. Most commonly an input message with a role and content.

type ResponseInputMessageContent added in v1.20.0

type ResponseInputMessageContent struct {
	// contains filtered or unexported fields
}

ResponseInputMessageContent Text or multimodal content for an input message. Either a string or a list of content parts.

func (ResponseInputMessageContent) AsResponseInputMessageContent0 added in v1.20.0

func (t ResponseInputMessageContent) AsResponseInputMessageContent0() (ResponseInputMessageContent0, error)

AsResponseInputMessageContent0 returns the union data inside the ResponseInputMessageContent as a ResponseInputMessageContent0

func (ResponseInputMessageContent) AsResponseInputMessageContent1 added in v1.20.0

func (t ResponseInputMessageContent) AsResponseInputMessageContent1() (ResponseInputMessageContent1, error)

AsResponseInputMessageContent1 returns the union data inside the ResponseInputMessageContent as a ResponseInputMessageContent1

func (*ResponseInputMessageContent) FromResponseInputMessageContent0 added in v1.20.0

func (t *ResponseInputMessageContent) FromResponseInputMessageContent0(v ResponseInputMessageContent0) error

FromResponseInputMessageContent0 overwrites any union data inside the ResponseInputMessageContent as the provided ResponseInputMessageContent0

func (*ResponseInputMessageContent) FromResponseInputMessageContent1 added in v1.20.0

func (t *ResponseInputMessageContent) FromResponseInputMessageContent1(v ResponseInputMessageContent1) error

FromResponseInputMessageContent1 overwrites any union data inside the ResponseInputMessageContent as the provided ResponseInputMessageContent1

func (ResponseInputMessageContent) MarshalJSON added in v1.20.0

func (t ResponseInputMessageContent) MarshalJSON() ([]byte, error)

func (*ResponseInputMessageContent) MergeResponseInputMessageContent0 added in v1.20.0

func (t *ResponseInputMessageContent) MergeResponseInputMessageContent0(v ResponseInputMessageContent0) error

MergeResponseInputMessageContent0 performs a merge with any union data inside the ResponseInputMessageContent, using the provided ResponseInputMessageContent0

func (*ResponseInputMessageContent) MergeResponseInputMessageContent1 added in v1.20.0

func (t *ResponseInputMessageContent) MergeResponseInputMessageContent1(v ResponseInputMessageContent1) error

MergeResponseInputMessageContent1 performs a merge with any union data inside the ResponseInputMessageContent, using the provided ResponseInputMessageContent1

func (*ResponseInputMessageContent) UnmarshalJSON added in v1.20.0

func (t *ResponseInputMessageContent) UnmarshalJSON(b []byte) error

type ResponseInputMessageContent0 added in v1.20.0

type ResponseInputMessageContent0 = string

ResponseInputMessageContent0 A text input to the model.

type ResponseInputMessageContent1 added in v1.20.0

type ResponseInputMessageContent1 = []ResponseInputContentPart

ResponseInputMessageContent1 defines model for ResponseInputMessageContent.1.

type ResponseInputText added in v1.20.0

type ResponseInputText struct {
	// Text The text input to the model.
	Text string `json:"text"`

	// Type The type of the input item. Always `input_text`.
	Type ResponseInputTextType `json:"type"`
}

ResponseInputText A text input to the model.

type ResponseInputTextType added in v1.20.0

type ResponseInputTextType string

ResponseInputTextType The type of the input item. Always `input_text`.

const (
	InputText ResponseInputTextType = "input_text"
)

Defines values for ResponseInputTextType.

func (ResponseInputTextType) Valid added in v1.20.0

func (e ResponseInputTextType) Valid() bool

Valid indicates whether the value is a known member of the ResponseInputTextType enum.

type ResponseOutputContent added in v1.20.0

type ResponseOutputContent struct {
	// contains filtered or unexported fields
}

ResponseOutputContent A content part of an output message.

func (ResponseOutputContent) AsResponseOutputRefusal added in v1.20.0

func (t ResponseOutputContent) AsResponseOutputRefusal() (ResponseOutputRefusal, error)

AsResponseOutputRefusal returns the union data inside the ResponseOutputContent as a ResponseOutputRefusal

func (ResponseOutputContent) AsResponseOutputText added in v1.20.0

func (t ResponseOutputContent) AsResponseOutputText() (ResponseOutputText, error)

AsResponseOutputText returns the union data inside the ResponseOutputContent as a ResponseOutputText

func (*ResponseOutputContent) FromResponseOutputRefusal added in v1.20.0

func (t *ResponseOutputContent) FromResponseOutputRefusal(v ResponseOutputRefusal) error

FromResponseOutputRefusal overwrites any union data inside the ResponseOutputContent as the provided ResponseOutputRefusal

func (*ResponseOutputContent) FromResponseOutputText added in v1.20.0

func (t *ResponseOutputContent) FromResponseOutputText(v ResponseOutputText) error

FromResponseOutputText overwrites any union data inside the ResponseOutputContent as the provided ResponseOutputText

func (ResponseOutputContent) MarshalJSON added in v1.20.0

func (t ResponseOutputContent) MarshalJSON() ([]byte, error)

func (*ResponseOutputContent) MergeResponseOutputRefusal added in v1.20.0

func (t *ResponseOutputContent) MergeResponseOutputRefusal(v ResponseOutputRefusal) error

MergeResponseOutputRefusal performs a merge with any union data inside the ResponseOutputContent, using the provided ResponseOutputRefusal

func (*ResponseOutputContent) MergeResponseOutputText added in v1.20.0

func (t *ResponseOutputContent) MergeResponseOutputText(v ResponseOutputText) error

MergeResponseOutputText performs a merge with any union data inside the ResponseOutputContent, using the provided ResponseOutputText

func (*ResponseOutputContent) UnmarshalJSON added in v1.20.0

func (t *ResponseOutputContent) UnmarshalJSON(b []byte) error

type ResponseOutputItem added in v1.20.0

type ResponseOutputItem struct {
	// contains filtered or unexported fields
}

ResponseOutputItem An output item generated by the model: an output message, a function tool call, or a reasoning item.

func (ResponseOutputItem) AsResponseFunctionToolCall added in v1.20.0

func (t ResponseOutputItem) AsResponseFunctionToolCall() (ResponseFunctionToolCall, error)

AsResponseFunctionToolCall returns the union data inside the ResponseOutputItem as a ResponseFunctionToolCall

func (ResponseOutputItem) AsResponseOutputMessage added in v1.20.0

func (t ResponseOutputItem) AsResponseOutputMessage() (ResponseOutputMessage, error)

AsResponseOutputMessage returns the union data inside the ResponseOutputItem as a ResponseOutputMessage

func (ResponseOutputItem) AsResponseReasoningItem added in v1.20.0

func (t ResponseOutputItem) AsResponseReasoningItem() (ResponseReasoningItem, error)

AsResponseReasoningItem returns the union data inside the ResponseOutputItem as a ResponseReasoningItem

func (*ResponseOutputItem) FromResponseFunctionToolCall added in v1.20.0

func (t *ResponseOutputItem) FromResponseFunctionToolCall(v ResponseFunctionToolCall) error

FromResponseFunctionToolCall overwrites any union data inside the ResponseOutputItem as the provided ResponseFunctionToolCall

func (*ResponseOutputItem) FromResponseOutputMessage added in v1.20.0

func (t *ResponseOutputItem) FromResponseOutputMessage(v ResponseOutputMessage) error

FromResponseOutputMessage overwrites any union data inside the ResponseOutputItem as the provided ResponseOutputMessage

func (*ResponseOutputItem) FromResponseReasoningItem added in v1.20.0

func (t *ResponseOutputItem) FromResponseReasoningItem(v ResponseReasoningItem) error

FromResponseReasoningItem overwrites any union data inside the ResponseOutputItem as the provided ResponseReasoningItem

func (ResponseOutputItem) MarshalJSON added in v1.20.0

func (t ResponseOutputItem) MarshalJSON() ([]byte, error)

func (*ResponseOutputItem) MergeResponseFunctionToolCall added in v1.20.0

func (t *ResponseOutputItem) MergeResponseFunctionToolCall(v ResponseFunctionToolCall) error

MergeResponseFunctionToolCall performs a merge with any union data inside the ResponseOutputItem, using the provided ResponseFunctionToolCall

func (*ResponseOutputItem) MergeResponseOutputMessage added in v1.20.0

func (t *ResponseOutputItem) MergeResponseOutputMessage(v ResponseOutputMessage) error

MergeResponseOutputMessage performs a merge with any union data inside the ResponseOutputItem, using the provided ResponseOutputMessage

func (*ResponseOutputItem) MergeResponseReasoningItem added in v1.20.0

func (t *ResponseOutputItem) MergeResponseReasoningItem(v ResponseReasoningItem) error

MergeResponseReasoningItem performs a merge with any union data inside the ResponseOutputItem, using the provided ResponseReasoningItem

func (*ResponseOutputItem) UnmarshalJSON added in v1.20.0

func (t *ResponseOutputItem) UnmarshalJSON(b []byte) error

type ResponseOutputMessage added in v1.20.0

type ResponseOutputMessage struct {
	Content []ResponseOutputContent `json:"content"`

	// ID The unique ID of the output message.
	ID string `json:"id"`

	// Role The role of the output message. Always `assistant`.
	Role ResponseOutputMessageRole `json:"role"`

	// Status The status of the message.
	Status *ResponseOutputMessageStatus `json:"status,omitempty"`

	// Type The type of the output item. Always `message`.
	Type ResponseOutputMessageType `json:"type"`
}

ResponseOutputMessage An output message from the model.

type ResponseOutputMessageRole added in v1.20.0

type ResponseOutputMessageRole string

ResponseOutputMessageRole The role of the output message. Always `assistant`.

const (
	ResponseOutputMessageRoleAssistant ResponseOutputMessageRole = "assistant"
)

Defines values for ResponseOutputMessageRole.

func (ResponseOutputMessageRole) Valid added in v1.20.0

func (e ResponseOutputMessageRole) Valid() bool

Valid indicates whether the value is a known member of the ResponseOutputMessageRole enum.

type ResponseOutputMessageStatus added in v1.20.0

type ResponseOutputMessageStatus string

ResponseOutputMessageStatus The status of the message.

const (
	ResponseOutputMessageStatusCompleted  ResponseOutputMessageStatus = "completed"
	ResponseOutputMessageStatusInProgress ResponseOutputMessageStatus = "in_progress"
	ResponseOutputMessageStatusIncomplete ResponseOutputMessageStatus = "incomplete"
)

Defines values for ResponseOutputMessageStatus.

func (ResponseOutputMessageStatus) Valid added in v1.20.0

Valid indicates whether the value is a known member of the ResponseOutputMessageStatus enum.

type ResponseOutputMessageType added in v1.20.0

type ResponseOutputMessageType string

ResponseOutputMessageType The type of the output item. Always `message`.

const (
	ResponseOutputMessageTypeMessage ResponseOutputMessageType = "message"
)

Defines values for ResponseOutputMessageType.

func (ResponseOutputMessageType) Valid added in v1.20.0

func (e ResponseOutputMessageType) Valid() bool

Valid indicates whether the value is a known member of the ResponseOutputMessageType enum.

type ResponseOutputRefusal added in v1.20.0

type ResponseOutputRefusal struct {
	// Refusal The refusal explanation from the model.
	Refusal string `json:"refusal"`

	// Type The type of the refusal. Always `refusal`.
	Type ResponseOutputRefusalType `json:"type"`
}

ResponseOutputRefusal A refusal generated by the model.

type ResponseOutputRefusalType added in v1.20.0

type ResponseOutputRefusalType string

ResponseOutputRefusalType The type of the refusal. Always `refusal`.

const (
	ResponseOutputRefusalTypeRefusal ResponseOutputRefusalType = "refusal"
)

Defines values for ResponseOutputRefusalType.

func (ResponseOutputRefusalType) Valid added in v1.20.0

func (e ResponseOutputRefusalType) Valid() bool

Valid indicates whether the value is a known member of the ResponseOutputRefusalType enum.

type ResponseOutputText added in v1.20.0

type ResponseOutputText struct {
	// Text The text output from the model.
	Text string `json:"text"`

	// Type The type of the output text. Always `output_text`.
	Type ResponseOutputTextType `json:"type"`
}

ResponseOutputText A text output from the model.

type ResponseOutputTextType added in v1.20.0

type ResponseOutputTextType string

ResponseOutputTextType The type of the output text. Always `output_text`.

const (
	OutputText ResponseOutputTextType = "output_text"
)

Defines values for ResponseOutputTextType.

func (ResponseOutputTextType) Valid added in v1.20.0

func (e ResponseOutputTextType) Valid() bool

Valid indicates whether the value is a known member of the ResponseOutputTextType enum.

type ResponseReasoning added in v1.20.0

type ResponseReasoning struct {
	// Effort Constrains the effort on reasoning for reasoning models. Reducing effort can result in faster responses and fewer reasoning tokens.
	Effort *ResponseReasoningEffort `json:"effort,omitempty"`

	// Summary A summary of the reasoning performed by the model, useful for debugging and understanding the model's reasoning process.
	Summary *ResponseReasoningSummary `json:"summary,omitempty"`
}

ResponseReasoning Configuration options for reasoning models.

type ResponseReasoningEffort added in v1.20.0

type ResponseReasoningEffort string

ResponseReasoningEffort Constrains the effort on reasoning for reasoning models. Reducing effort can result in faster responses and fewer reasoning tokens.

const (
	ResponseReasoningEffortHigh    ResponseReasoningEffort = "high"
	ResponseReasoningEffortLow     ResponseReasoningEffort = "low"
	ResponseReasoningEffortMedium  ResponseReasoningEffort = "medium"
	ResponseReasoningEffortMinimal ResponseReasoningEffort = "minimal"
)

Defines values for ResponseReasoningEffort.

func (ResponseReasoningEffort) Valid added in v1.20.0

func (e ResponseReasoningEffort) Valid() bool

Valid indicates whether the value is a known member of the ResponseReasoningEffort enum.

type ResponseReasoningItem added in v1.20.0

type ResponseReasoningItem struct {
	// ID The unique ID of the reasoning item.
	ID string `json:"id"`

	// Status The status of the reasoning item.
	Status *ResponseReasoningItemStatus `json:"status,omitempty"`

	// Summary Reasoning summary content.
	Summary []ResponseReasoningSummaryPart `json:"summary"`

	// Type The type of the output item. Always `reasoning`.
	Type ResponseReasoningItemType `json:"type"`
}

ResponseReasoningItem A reasoning item describing the model's chain of thought.

type ResponseReasoningItemStatus added in v1.20.0

type ResponseReasoningItemStatus string

ResponseReasoningItemStatus The status of the reasoning item.

const (
	ResponseReasoningItemStatusCompleted  ResponseReasoningItemStatus = "completed"
	ResponseReasoningItemStatusInProgress ResponseReasoningItemStatus = "in_progress"
	ResponseReasoningItemStatusIncomplete ResponseReasoningItemStatus = "incomplete"
)

Defines values for ResponseReasoningItemStatus.

func (ResponseReasoningItemStatus) Valid added in v1.20.0

Valid indicates whether the value is a known member of the ResponseReasoningItemStatus enum.

type ResponseReasoningItemType added in v1.20.0

type ResponseReasoningItemType string

ResponseReasoningItemType The type of the output item. Always `reasoning`.

const (
	Reasoning ResponseReasoningItemType = "reasoning"
)

Defines values for ResponseReasoningItemType.

func (ResponseReasoningItemType) Valid added in v1.20.0

func (e ResponseReasoningItemType) Valid() bool

Valid indicates whether the value is a known member of the ResponseReasoningItemType enum.

type ResponseReasoningSummary added in v1.20.0

type ResponseReasoningSummary string

ResponseReasoningSummary A summary of the reasoning performed by the model, useful for debugging and understanding the model's reasoning process.

const (
	ResponseReasoningSummaryAuto     ResponseReasoningSummary = "auto"
	ResponseReasoningSummaryConcise  ResponseReasoningSummary = "concise"
	ResponseReasoningSummaryDetailed ResponseReasoningSummary = "detailed"
)

Defines values for ResponseReasoningSummary.

func (ResponseReasoningSummary) Valid added in v1.20.0

func (e ResponseReasoningSummary) Valid() bool

Valid indicates whether the value is a known member of the ResponseReasoningSummary enum.

type ResponseReasoningSummaryPart added in v1.20.0

type ResponseReasoningSummaryPart struct {
	// Text A summary of the reasoning output from the model.
	Text string `json:"text"`

	// Type The type of the summary. Always `summary_text`.
	Type ResponseReasoningSummaryPartType `json:"type"`
}

ResponseReasoningSummaryPart A summary part of a reasoning item.

type ResponseReasoningSummaryPartType added in v1.23.0

type ResponseReasoningSummaryPartType string

ResponseReasoningSummaryPartType The type of the summary. Always `summary_text`.

const (
	SummaryText ResponseReasoningSummaryPartType = "summary_text"
)

Defines values for ResponseReasoningSummaryPartType.

func (ResponseReasoningSummaryPartType) Valid added in v1.23.0

Valid indicates whether the value is a known member of the ResponseReasoningSummaryPartType enum.

type ResponseRole added in v1.20.0

type ResponseRole string

ResponseRole The role of the message input.

const (
	ResponseRoleAssistant ResponseRole = "assistant"
	ResponseRoleDeveloper ResponseRole = "developer"
	ResponseRoleSystem    ResponseRole = "system"
	ResponseRoleUser      ResponseRole = "user"
)

Defines values for ResponseRole.

func (ResponseRole) Valid added in v1.20.0

func (e ResponseRole) Valid() bool

Valid indicates whether the value is a known member of the ResponseRole enum.

type ResponseStatus added in v1.20.0

type ResponseStatus string

ResponseStatus The status of the response generation.

const (
	ResponseStatusCancelled  ResponseStatus = "cancelled"
	ResponseStatusCompleted  ResponseStatus = "completed"
	ResponseStatusFailed     ResponseStatus = "failed"
	ResponseStatusInProgress ResponseStatus = "in_progress"
	ResponseStatusIncomplete ResponseStatus = "incomplete"
	ResponseStatusQueued     ResponseStatus = "queued"
)

Defines values for ResponseStatus.

func (ResponseStatus) Valid added in v1.20.0

func (e ResponseStatus) Valid() bool

Valid indicates whether the value is a known member of the ResponseStatus enum.

type ResponseStreamEvent added in v1.20.0

type ResponseStreamEvent struct {
	// ContentIndex The index of the content part within the output item.
	ContentIndex *int `json:"content_index,omitempty"`

	// Delta The incremental text delta for `*.delta` events.
	Delta *string `json:"delta,omitempty"`

	// ItemID The ID of the output item this event relates to.
	ItemID *string `json:"item_id,omitempty"`

	// OutputIndex The index of the output item in the response's output array.
	OutputIndex *int `json:"output_index,omitempty"`

	// Response Represents a model response returned by the Responses API.
	Response *Response `json:"response,omitempty"`

	// SequenceNumber The sequence number of this event.
	SequenceNumber *int `json:"sequence_number,omitempty"`

	// Text The finalized text for `*.done` events.
	Text *string `json:"text,omitempty"`

	// Type The type of the streamed event, for example `response.output_text.delta` or `response.completed`.
	Type string `json:"type"`
}

ResponseStreamEvent A server-sent event emitted while streaming a response. The Responses API emits a sequence of typed events (for example `response.created`, `response.output_text.delta`, and `response.completed`). This schema models the common event envelope; which fields are populated depends on the event `type`.

type ResponseTextConfig added in v1.20.0

type ResponseTextConfig struct {
	// Format An object specifying the format that the model must output.
	Format *struct {
		// Name The name of the response format (used with `json_schema`).
		Name *string `json:"name,omitempty"`

		// Schema The parameters the functions accepts, described as a JSON Schema object. See the [guide](/docs/guides/function-calling) for examples, and the [JSON Schema reference](https://json-schema.org/understanding-json-schema/) for documentation about the format.
		// Omitting `parameters` defines a function with an empty parameter list.
		Schema *FunctionParameters `json:"schema,omitempty"`

		// Strict Whether to enable strict schema adherence.
		Strict *bool `json:"strict,omitempty"`

		// Type The type of response format being defined.
		Type ResponseTextConfigFormatType `json:"type"`
	} `json:"format,omitempty"`
}

ResponseTextConfig Configuration options for a text response from the model. Can be plain text or structured JSON data.

type ResponseTextConfigFormatType added in v1.20.0

type ResponseTextConfigFormatType string

ResponseTextConfigFormatType The type of response format being defined.

const (
	ResponseTextConfigFormatTypeJSONObject ResponseTextConfigFormatType = "json_object"
	ResponseTextConfigFormatTypeJSONSchema ResponseTextConfigFormatType = "json_schema"
	ResponseTextConfigFormatTypeText       ResponseTextConfigFormatType = "text"
)

Defines values for ResponseTextConfigFormatType.

func (ResponseTextConfigFormatType) Valid added in v1.20.0

Valid indicates whether the value is a known member of the ResponseTextConfigFormatType enum.

type ResponseTool added in v1.20.0

type ResponseTool struct {
	// Description A description of the function, used by the model to decide when and how to call it.
	Description *string `json:"description,omitempty"`

	// Name The name of the function to call.
	Name string `json:"name"`

	// Parameters The parameters the functions accepts, described as a JSON Schema object. See the [guide](/docs/guides/function-calling) for examples, and the [JSON Schema reference](https://json-schema.org/understanding-json-schema/) for documentation about the format.
	// Omitting `parameters` defines a function with an empty parameter list.
	Parameters *FunctionParameters `json:"parameters,omitempty"`

	// Strict Whether to enforce strict parameter validation.
	Strict *bool `json:"strict,omitempty"`

	// Type The type of the tool. Currently only `function`.
	Type ResponseToolType `json:"type"`
}

ResponseTool A tool the model may call. Only function tools are modeled here. Note the Responses API uses a flattened function tool shape (`name`, `description`, and `parameters` at the top level) rather than nesting them under a `function` object as `/chat/completions` does.

type ResponseToolChoice added in v1.20.0

type ResponseToolChoice struct {
	// contains filtered or unexported fields
}

ResponseToolChoice How the model should select which tool (or tools) to use. Either a mode string (`none`, `auto`, `required`) or an object forcing a specific tool.

func (ResponseToolChoice) AsResponseToolChoice0 added in v1.20.0

func (t ResponseToolChoice) AsResponseToolChoice0() (ResponseToolChoice0, error)

AsResponseToolChoice0 returns the union data inside the ResponseToolChoice as a ResponseToolChoice0

func (ResponseToolChoice) AsResponseToolChoice1 added in v1.20.0

func (t ResponseToolChoice) AsResponseToolChoice1() (ResponseToolChoice1, error)

AsResponseToolChoice1 returns the union data inside the ResponseToolChoice as a ResponseToolChoice1

func (*ResponseToolChoice) FromResponseToolChoice0 added in v1.20.0

func (t *ResponseToolChoice) FromResponseToolChoice0(v ResponseToolChoice0) error

FromResponseToolChoice0 overwrites any union data inside the ResponseToolChoice as the provided ResponseToolChoice0

func (*ResponseToolChoice) FromResponseToolChoice1 added in v1.20.0

func (t *ResponseToolChoice) FromResponseToolChoice1(v ResponseToolChoice1) error

FromResponseToolChoice1 overwrites any union data inside the ResponseToolChoice as the provided ResponseToolChoice1

func (ResponseToolChoice) MarshalJSON added in v1.20.0

func (t ResponseToolChoice) MarshalJSON() ([]byte, error)

func (*ResponseToolChoice) MergeResponseToolChoice0 added in v1.20.0

func (t *ResponseToolChoice) MergeResponseToolChoice0(v ResponseToolChoice0) error

MergeResponseToolChoice0 performs a merge with any union data inside the ResponseToolChoice, using the provided ResponseToolChoice0

func (*ResponseToolChoice) MergeResponseToolChoice1 added in v1.20.0

func (t *ResponseToolChoice) MergeResponseToolChoice1(v ResponseToolChoice1) error

MergeResponseToolChoice1 performs a merge with any union data inside the ResponseToolChoice, using the provided ResponseToolChoice1

func (*ResponseToolChoice) UnmarshalJSON added in v1.20.0

func (t *ResponseToolChoice) UnmarshalJSON(b []byte) error

type ResponseToolChoice0 added in v1.20.0

type ResponseToolChoice0 string

ResponseToolChoice0 The tool-choice mode.

const (
	ResponseToolChoice0Auto     ResponseToolChoice0 = "auto"
	ResponseToolChoice0None     ResponseToolChoice0 = "none"
	ResponseToolChoice0Required ResponseToolChoice0 = "required"
)

Defines values for ResponseToolChoice0.

func (ResponseToolChoice0) Valid added in v1.20.0

func (e ResponseToolChoice0) Valid() bool

Valid indicates whether the value is a known member of the ResponseToolChoice0 enum.

type ResponseToolChoice1 added in v1.20.0

type ResponseToolChoice1 struct {
	Name string                  `json:"name"`
	Type ResponseToolChoice1Type `json:"type"`
}

ResponseToolChoice1 Forces the model to call a specific function tool.

type ResponseToolChoice1Type added in v1.20.0

type ResponseToolChoice1Type string

ResponseToolChoice1Type defines model for ResponseToolChoice.1.Type.

const (
	ResponseToolChoiceTypeFunction ResponseToolChoice1Type = "function"
)

Defines values for ResponseToolChoice1Type.

func (ResponseToolChoice1Type) Valid added in v1.20.0

func (e ResponseToolChoice1Type) Valid() bool

Valid indicates whether the value is a known member of the ResponseToolChoice1Type enum.

type ResponseToolType added in v1.20.0

type ResponseToolType string

ResponseToolType The type of the tool. Currently only `function`.

const (
	ResponseToolTypeFunction ResponseToolType = "function"
)

Defines values for ResponseToolType.

func (ResponseToolType) Valid added in v1.20.0

func (e ResponseToolType) Valid() bool

Valid indicates whether the value is a known member of the ResponseToolType enum.

type ResponseUsage added in v1.20.0

type ResponseUsage struct {
	// InputTokens The number of input tokens.
	InputTokens int64 `json:"input_tokens"`

	// InputTokensDetails A detailed breakdown of the input tokens.
	InputTokensDetails *struct {
		// CachedTokens The number of tokens retrieved from the cache.
		CachedTokens *int64 `json:"cached_tokens,omitempty"`
	} `json:"input_tokens_details,omitempty"`

	// OutputTokens The number of output tokens.
	OutputTokens int64 `json:"output_tokens"`

	// OutputTokensDetails A detailed breakdown of the output tokens.
	OutputTokensDetails *struct {
		// ReasoningTokens The number of reasoning tokens.
		ReasoningTokens *int64 `json:"reasoning_tokens,omitempty"`
	} `json:"output_tokens_details,omitempty"`

	// TotalTokens The total number of tokens used (input + output).
	TotalTokens int64 `json:"total_tokens"`
}

ResponseUsage Token usage details for the response.

type ResponsesNotSupported added in v1.20.0

type ResponsesNotSupported = Error

ResponsesNotSupported defines model for ResponsesNotSupported.

type RetryConfig added in v1.12.0

type RetryConfig struct {
	// Enabled controls whether retry logic is enabled
	Enabled bool
	// MaxAttempts is the maximum number of retry attempts (including initial request)
	MaxAttempts int
	// InitialBackoffSec is the initial backoff delay in seconds
	InitialBackoffSec int
	// MaxBackoffSec is the maximum backoff delay in seconds
	MaxBackoffSec int
	// BackoffMultiplier is the multiplier for exponential backoff
	BackoffMultiplier int
	// RetryableStatusCodes is a custom list of HTTP status codes that should trigger a retry.
	// If nil or empty, uses default status codes (408, 429, 500, 502, 503, 504)
	RetryableStatusCodes []int
	// OnRetry is called before each retry attempt with attempt number, error, and delay.
	// The attempt number starts from 1 for the first retry (after initial request fails)
	OnRetry func(attempt int, err error, delay time.Duration)
}

RetryConfig represents the retry configuration for HTTP requests

type SSEvent added in v1.4.0

type SSEvent struct {
	Data  *[]byte       `json:"data,omitempty"`
	Event *SSEventEvent `json:"event,omitempty"`
	Retry *int          `json:"retry,omitempty"`
}

SSEvent defines model for SSEvent.

type SSEventEvent added in v1.5.0

type SSEventEvent string

SSEventEvent defines model for SSEvent.Event.

const (
	SSEventEventContentDelta SSEventEvent = "content-delta"
	SSEventEventContentEnd   SSEventEvent = "content-end"
	SSEventEventContentStart SSEventEvent = "content-start"
	SSEventEventMessageEnd   SSEventEvent = "message-end"
	SSEventEventMessageStart SSEventEvent = "message-start"
	SSEventEventStreamEnd    SSEventEvent = "stream-end"
	SSEventEventStreamStart  SSEventEvent = "stream-start"
)

Defines values for SSEventEvent.

func (SSEventEvent) Valid added in v1.16.0

func (e SSEventEvent) Valid() bool

Valid indicates whether the value is a known member of the SSEventEvent enum.

type TextContentPart added in v1.14.0

type TextContentPart struct {
	// Text The text content
	Text string `json:"text"`

	// Type Content type identifier
	Type TextContentPartType `json:"type"`
}

TextContentPart Text content part

type TextContentPartType added in v1.14.0

type TextContentPartType string

TextContentPartType Content type identifier

const (
	TextContentPartTypeText TextContentPartType = "text"
)

Defines values for TextContentPartType.

func (TextContentPartType) Valid added in v1.16.0

func (e TextContentPartType) Valid() bool

Valid indicates whether the value is a known member of the TextContentPartType enum.

type ToolCallExtraContent added in v1.16.0

type ToolCallExtraContent struct {
	// Google Google Gemini-specific extra content.
	Google *ToolCallExtraContent_Google `json:"google,omitempty"`
}

ToolCallExtraContent Provider-specific opaque data attached to a tool call. The contents are not interpreted by the gateway, but must be echoed back verbatim on the next request that references this tool call. Currently used by Google Gemini extended-thinking models to carry the per-call `thought_signature`. Other providers may ignore the field.

type ToolCallExtraContent_Google added in v1.16.0

type ToolCallExtraContent_Google struct {
	// ThoughtSignature Opaque signature returned with reasoning-enabled tool calls.
	// Must be echoed back verbatim in the next request that includes
	// this tool call, or Google will reject the request.
	ThoughtSignature     *string        `json:"thought_signature,omitempty"`
	AdditionalProperties map[string]any `json:"-"`
}

ToolCallExtraContent_Google Google Gemini-specific extra content.

func (ToolCallExtraContent_Google) Get added in v1.16.0

func (a ToolCallExtraContent_Google) Get(fieldName string) (value any, found bool)

Getter for additional properties for ToolCallExtraContent_Google. Returns the specified element and whether it was found

func (ToolCallExtraContent_Google) MarshalJSON added in v1.16.0

func (a ToolCallExtraContent_Google) MarshalJSON() ([]byte, error)

Override default JSON handling for ToolCallExtraContent_Google to handle AdditionalProperties

func (*ToolCallExtraContent_Google) Set added in v1.16.0

func (a *ToolCallExtraContent_Google) Set(fieldName string, value any)

Setter for additional properties for ToolCallExtraContent_Google

func (*ToolCallExtraContent_Google) UnmarshalJSON added in v1.16.0

func (a *ToolCallExtraContent_Google) UnmarshalJSON(b []byte) error

Override default JSON handling for ToolCallExtraContent_Google to handle AdditionalProperties

type Unauthorized added in v1.5.0

type Unauthorized = Error

Unauthorized defines model for Unauthorized.

Directories

Path Synopsis
examples
vision command

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL