sdk

package module
v1.21.0 Latest Latest
Warning

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

Go to latest
Published: Jul 11, 2026 License: Apache-2.0 Imports: 13 Imported by: 7

README

🚀 Inference Gateway Go SDK

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

Go Reference Go Report Card 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)
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)
        }
    }
}
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.7.2 DO NOT EDIT.

Index

Constants

View Source
const (
	BearerAuthScopes bearerAuthContextKey = "bearerAuth.Scopes"
)

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 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) (*ListModelsResponse, error)
	ListProviderModels(ctx context.Context, provider Provider) (*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)
	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
}

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"`

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

	// 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 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.

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 .

type CreateChatCompletionRequestStop1 added in v1.18.0

type CreateChatCompletionRequestStop1 = []string

CreateChatCompletionRequestStop1 defines model for .

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 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 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 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 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"`
}

ListModelsParams defines parameters for ListModels.

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 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 Model

type Model struct {
	Created  int64    `json:"created"`
	ID       string   `json:"id"`
	Object   string   `json:"object"`
	OwnedBy  string   `json:"owned_by"`
	ServedBy Provider `json:"served_by"`
}

Model Common model information

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"
	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 .

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 (
	Refusal 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 ResponseReasoningSummaryType `json:"type"`
}

ResponseReasoningSummaryPart A summary part of a reasoning item.

type ResponseReasoningSummaryType added in v1.20.0

type ResponseReasoningSummaryType string

ResponseReasoningSummaryType The type of the summary. Always `summary_text`.

const (
	SummaryText ResponseReasoningSummaryType = "summary_text"
)

Defines values for ResponseReasoningSummaryType.

func (ResponseReasoningSummaryType) Valid added in v1.20.0

Valid indicates whether the value is a known member of the ResponseReasoningSummaryType 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 (
	Auto     ResponseToolChoice0 = "auto"
	None     ResponseToolChoice0 = "none"
	Required 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 (
	ContentDelta SSEventEvent = "content-delta"
	ContentEnd   SSEventEvent = "content-end"
	ContentStart SSEventEvent = "content-start"
	MessageEnd   SSEventEvent = "message-end"
	MessageStart SSEventEvent = "message-start"
	StreamEnd    SSEventEvent = "stream-end"
	StreamStart  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