gopenrouter

package module
v0.0.0-...-c8a7c06 Latest Latest
Warning

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

Go to latest
Published: Jul 29, 2026 License: MIT Imports: 21 Imported by: 0

README

gopenrouter

Go Reference Go Report Card Go Version License

gopenrouter is a Go client for the OpenRouter API. It combines the complete generated interface from OpenRouter's official Go SDK with an ergonomic, go-openai-style compatibility interface.

Use one client for both surfaces:

  • the generated namespaces expose the complete typed OpenRouter API, including Chat, Responses, Images, Files, audio, embeddings, reranking, video, analytics, BYOK, presets, observability, guardrails, workspaces, and API-key management;
  • the compatibility methods provide a compact interface for chat completions, streaming, Anthropic Messages, Responses, embeddings, model discovery, generation metadata, credits, OAuth, and management operations.

Requirements

  • Go 1.25.10 or newer
  • an OpenRouter API key

The official SDK version used by the generated surface is pinned in go.mod.

Installation

go get github.com/iamwavecut/gopenrouter@main

Quick start

package main

import (
	"context"
	"fmt"
	"log"
	"os"

	"github.com/iamwavecut/gopenrouter"
)

func main() {
	client := gopenrouter.NewClient(os.Getenv("OPENROUTER_API_KEY"))

	response, err := client.CreateChatCompletion(
		context.Background(),
		gopenrouter.ChatCompletionRequest{
			Model: "openai/gpt-5-nano",
			Messages: []gopenrouter.ChatCompletionMessage{
				{
					Role:    gopenrouter.RoleUser,
					Content: "Explain why the sky is blue in one sentence.",
				},
			},
		},
	)
	if err != nil {
		log.Fatal(err)
	}

	fmt.Println(response.Choices[0].Message.Content)
}

Generated OpenRouter interface

Client embeds OpenRouter's generated Go client. Its namespaces and exact request, response, union, multipart, pagination, binary, error, and event-stream types are available directly:

client := gopenrouter.NewClient(os.Getenv("OPENROUTER_API_KEY"))

models, err := client.Models.List(ctx, nil)
files, err := client.Files.List(ctx, nil)
responses, err := client.Responses.Send(ctx, request, nil)

Generated model types live under github.com/OpenRouterTeam/go-sdk/models. The client currently exposes these top-level namespaces:

Analytics, APIKeys, Benchmarks, Beta, Byok, Chat, Classifications, Credits, Datasets, Embeddings, Endpoints, Files, Generations, Guardrails, Images, Models, OAuth, Observability, Organization, Presets, Providers, Rerank, Responses, Stt, Tts, VideoGeneration, and Workspaces.

Compatibility interface

The root methods retain the library's concise, go-openai-inspired API:

response, err := client.CreateChatCompletion(ctx, request)
stream, err := client.CreateChatCompletionStream(ctx, request)

embedding, err := client.CreateEmbeddings(ctx, embeddingRequest)
anthropic, err := client.CreateAnthropicMessage(ctx, anthropicRequest)
responses, err := client.CreateResponse(ctx, responsesRequest)
generation, err := client.GetGeneration(ctx, generationID)

The catalog, embeddings, responses, anthropic, oauth, management, and shared packages provide the same compatibility contracts in focused namespaces.

The compatibility surface also covers POST /messages and the deprecated POST /credits/coinbase operation, which are present in OpenRouter's public OpenAPI contract but intentionally omitted from the generated official client.

Configuration

config := gopenrouter.DefaultConfig(os.Getenv("OPENROUTER_API_KEY"))
config.HTTPClient = &http.Client{Timeout: 2 * time.Minute}
config.SiteURL = "https://example.com"
config.SiteName = "Example application"
config.SiteCategories = []string{"productivity", "developer-tools"}

client := gopenrouter.NewClientWithConfig(config)

The configuration is shared by both client surfaces and controls:

  • bearer authentication;
  • the base URL and HTTP client;
  • HTTP-Referer, X-Title, and X-OpenRouter-Title;
  • X-OpenRouter-Categories.

OpenRouter-specific capabilities

  • provider routing, fallback model lists, provider preferences, ZDR and region selection;
  • reasoning controls and reasoning details;
  • prompt caching and cache-control directives;
  • structured outputs, tools, server tools, and plugins;
  • text, image, audio, file, embedding, rerank, and video payloads;
  • cost and native-token accounting;
  • typed synchronous and streaming errors;
  • Chat SSE, Responses semantic events, and Anthropic event streams.

Examples

Runnable programs are available in examples/:

API parity

The repository checks API coverage against a pinned official OpenAPI snapshot, maps every documented HTTP operation to a callable client method, inventories the complete official documentation corpus, and tests current schema and streaming contracts.

The reproducible source hashes, upstream client revisions, documented source lag, and verification commands are recorded in the parity evidence.

Credits

The compatibility interface is inspired by go-openai. The complete generated surface is provided by OpenRouter's official Go SDK.

License

MIT

Documentation

Index

Constants

View Source
const (
	RoleUser      = "user"
	RoleAssistant = "assistant"
	RoleSystem    = "system"
	RoleTool      = "tool"
	RoleDeveloper = "developer"
)
View Source
const (
	// Deprecated: use shared.DataCollectionAllow from package github.com/iamwavecut/gopenrouter/shared.
	DataCollectionAllow = shared.DataCollectionAllow
	// Deprecated: use shared.DataCollectionDeny from package github.com/iamwavecut/gopenrouter/shared.
	DataCollectionDeny = shared.DataCollectionDeny
)
View Source
const (
	// Deprecated: use shared.ProviderSortPrice from package github.com/iamwavecut/gopenrouter/shared.
	ProviderSortPrice = shared.ProviderSortPrice
	// Deprecated: use shared.ProviderSortThroughput from package github.com/iamwavecut/gopenrouter/shared.
	ProviderSortThroughput = shared.ProviderSortThroughput
	// Deprecated: use shared.ProviderSortLatency from package github.com/iamwavecut/gopenrouter/shared.
	ProviderSortLatency = shared.ProviderSortLatency
)
View Source
const (
	// Deprecated: use shared.ProviderSortPartitionModel from package github.com/iamwavecut/gopenrouter/shared.
	ProviderSortPartitionModel = shared.ProviderSortPartitionModel
	// Deprecated: use shared.ProviderSortPartitionNone from package github.com/iamwavecut/gopenrouter/shared.
	ProviderSortPartitionNone = shared.ProviderSortPartitionNone
)
View Source
const (
	// Deprecated: use shared.PluginIDAutoRouter from package github.com/iamwavecut/gopenrouter/shared.
	PluginIDAutoRouter = shared.PluginIDAutoRouter
	// Deprecated: use shared.PluginIDModeration from package github.com/iamwavecut/gopenrouter/shared.
	PluginIDModeration = shared.PluginIDModeration
	// Deprecated: use shared.PluginIDFileParser from package github.com/iamwavecut/gopenrouter/shared.
	PluginIDFileParser = shared.PluginIDFileParser
	// Deprecated: use shared.PluginIDWeb from package github.com/iamwavecut/gopenrouter/shared.
	PluginIDWeb = shared.PluginIDWeb
	// Deprecated: use shared.PluginIDResponseHealing from package github.com/iamwavecut/gopenrouter/shared.
	PluginIDResponseHealing = shared.PluginIDResponseHealing
)
View Source
const (
	// Deprecated: use shared.PDFEngineMistralOCR from package github.com/iamwavecut/gopenrouter/shared.
	PDFEngineMistralOCR = shared.PDFEngineMistralOCR
	// Deprecated: use shared.PDFEnginePDFText from package github.com/iamwavecut/gopenrouter/shared.
	PDFEnginePDFText = shared.PDFEnginePDFText
	// Deprecated: use shared.PDFEngineNative from package github.com/iamwavecut/gopenrouter/shared.
	PDFEngineNative = shared.PDFEngineNative
)
View Source
const (
	// Deprecated: use shared.SearchContextSizeLow from package github.com/iamwavecut/gopenrouter/shared.
	SearchContextSizeLow = shared.SearchContextSizeLow
	// Deprecated: use shared.SearchContextSizeMedium from package github.com/iamwavecut/gopenrouter/shared.
	SearchContextSizeMedium = shared.SearchContextSizeMedium
	// Deprecated: use shared.SearchContextSizeHigh from package github.com/iamwavecut/gopenrouter/shared.
	SearchContextSizeHigh = shared.SearchContextSizeHigh
)

Variables

This section is empty.

Functions

func GenerateSchema

func GenerateSchema(v any) (map[string]any, error)

GenerateSchema creates a JSON schema from a Go struct. It uses reflection to generate a JSON schema from the struct's fields and tags.

Types

type APIError deprecated

type APIError = shared.APIError

Deprecated: use shared.APIError from package github.com/iamwavecut/gopenrouter/shared.

type APIKeyResponse deprecated

type APIKeyResponse = managementpkg.APIKeyResponse

Deprecated: use management.APIKeyResponse from package github.com/iamwavecut/gopenrouter/management.

type APIKeysListParams deprecated

type APIKeysListParams = managementpkg.APIKeysListParams

Deprecated: use management.APIKeysListParams from package github.com/iamwavecut/gopenrouter/management.

type APIKeysResponse deprecated

type APIKeysResponse = managementpkg.APIKeysResponse

Deprecated: use management.APIKeysResponse from package github.com/iamwavecut/gopenrouter/management.

type ActivityItem deprecated

type ActivityItem = managementpkg.ActivityItem

Deprecated: use management.ActivityItem from package github.com/iamwavecut/gopenrouter/management.

type ActivityParams deprecated

type ActivityParams = managementpkg.ActivityParams

Deprecated: use management.ActivityParams from package github.com/iamwavecut/gopenrouter/management.

type ActivityResponse deprecated

type ActivityResponse = managementpkg.ActivityResponse

Deprecated: use management.ActivityResponse from package github.com/iamwavecut/gopenrouter/management.

type AnthropicContentBlock deprecated

type AnthropicContentBlock = anthropicpkg.ContentBlock

Deprecated: use anthropic.ContentBlock from package github.com/iamwavecut/gopenrouter/anthropic.

type AnthropicMessage deprecated

type AnthropicMessage = anthropicpkg.Message

Deprecated: use anthropic.Message from package github.com/iamwavecut/gopenrouter/anthropic.

type AnthropicMessageRequest deprecated

type AnthropicMessageRequest = anthropicpkg.Request

Deprecated: use anthropic.Request from package github.com/iamwavecut/gopenrouter/anthropic.

type AnthropicMessageResponse deprecated

type AnthropicMessageResponse = anthropicpkg.Response

Deprecated: use anthropic.Response from package github.com/iamwavecut/gopenrouter/anthropic.

type AnthropicMessageStream deprecated

type AnthropicMessageStream = anthropicpkg.Stream

Deprecated: use anthropic.Stream from package github.com/iamwavecut/gopenrouter/anthropic.

type AnthropicMessageStreamEvent deprecated

type AnthropicMessageStreamEvent = anthropicpkg.StreamEvent

Deprecated: use anthropic.StreamEvent from package github.com/iamwavecut/gopenrouter/anthropic.

type AnthropicTool deprecated

type AnthropicTool = anthropicpkg.Tool

Deprecated: use anthropic.Tool from package github.com/iamwavecut/gopenrouter/anthropic.

type AuthCode deprecated

type AuthCode = oauthpkg.AuthCode

Deprecated: use oauth.AuthCode from package github.com/iamwavecut/gopenrouter/oauth.

type BigNumber deprecated

type BigNumber = shared.BigNumber

Deprecated: use shared.BigNumber from package github.com/iamwavecut/gopenrouter/shared.

type BulkAssignKeysRequest deprecated

type BulkAssignKeysRequest = managementpkg.BulkAssignKeysRequest

Deprecated: use management.BulkAssignKeysRequest from package github.com/iamwavecut/gopenrouter/management.

type BulkAssignMembersRequest deprecated

type BulkAssignMembersRequest = managementpkg.BulkAssignMembersRequest

Deprecated: use management.BulkAssignMembersRequest from package github.com/iamwavecut/gopenrouter/management.

type CacheControl deprecated

type CacheControl = shared.CacheControl

Deprecated: use shared.CacheControl from package github.com/iamwavecut/gopenrouter/shared.

type ChatCompletionChoiceLogprobs

type ChatCompletionChoiceLogprobs struct {
	Content []ChatCompletionTokenLogprob `json:"content,omitempty"`
	Refusal []ChatCompletionTokenLogprob `json:"refusal,omitempty"`
}

type ChatCompletionMessage

type ChatCompletionMessage struct {
	Role         ChatCompletionMessageRole   `json:"role"`
	Content      string                      `json:"content,omitempty"`
	MultiContent []ChatCompletionMessagePart `json:"-"`

	Name       string     `json:"name,omitempty"`
	ToolCalls  []ToolCall `json:"tool_calls,omitempty"`
	ToolCallID string     `json:"tool_call_id,omitempty"`
	Refusal    string     `json:"refusal,omitempty"`

	Reasoning        string            `json:"reasoning,omitempty"`
	ReasoningDetails []ReasoningDetail `json:"reasoning_details,omitempty"`
	Images           []GeneratedImage  `json:"images,omitempty"`
}

func (ChatCompletionMessage) MarshalJSON

func (m ChatCompletionMessage) MarshalJSON() ([]byte, error)

func (*ChatCompletionMessage) UnmarshalJSON

func (m *ChatCompletionMessage) UnmarshalJSON(data []byte) error

type ChatCompletionMessagePart

type ChatCompletionMessagePart struct {
	Type         string        `json:"type"`
	Text         string        `json:"text,omitempty"`
	ImageURL     *ImageURL     `json:"image_url,omitempty"`
	File         *File         `json:"file,omitempty"`
	InputAudio   *InputAudio   `json:"input_audio,omitempty"`
	VideoURL     *VideoInput   `json:"video_url,omitempty"`
	CacheControl *CacheControl `json:"cache_control,omitempty"`
}

type ChatCompletionMessageRole

type ChatCompletionMessageRole string

type ChatCompletionRequest

type ChatCompletionRequest struct {
	Model         string                  `json:"model,omitempty"`
	Messages      []ChatCompletionMessage `json:"messages,omitempty"`
	Temperature   float64                 `json:"temperature,omitempty"`
	TopP          float64                 `json:"top_p,omitempty"`
	N             int                     `json:"n,omitempty"`
	Stream        bool                    `json:"stream,omitempty"`
	StreamOptions *StreamOptions          `json:"stream_options,omitempty"`
	Stop          []string                `json:"stop,omitempty"`
	// Deprecated: use MaxCompletionTokens instead.
	MaxTokens           int             `json:"max_tokens,omitempty"`
	MaxCompletionTokens *int            `json:"max_completion_tokens,omitempty"`
	PresencePenalty     float64         `json:"presence_penalty,omitempty"`
	FrequencyPenalty    float64         `json:"frequency_penalty,omitempty"`
	LogitBias           map[string]int  `json:"logit_bias,omitempty"`
	User                string          `json:"user,omitempty"`
	Seed                *int            `json:"seed,omitempty"`
	Tools               []Tool          `json:"tools,omitempty"`
	ToolChoice          any             `json:"tool_choice,omitempty"`
	LogProbs            *bool           `json:"logprobs,omitempty"`
	ResponseFormat      *ResponseFormat `json:"response_format,omitempty"`
	TopK                *float64        `json:"top_k,omitempty"`
	RepetitionPenalty   *float64        `json:"repetition_penalty,omitempty"`
	TopLogProbs         *int            `json:"top_logprobs,omitempty"`
	MinP                *float64        `json:"min_p,omitempty"`
	TopA                *float64        `json:"top_a,omitempty"`
	Prediction          *Prediction     `json:"prediction,omitempty"`

	Models []string `json:"models,omitempty"`
	// Deprecated: use Provider.Sort.Config.Partition instead.
	Route             string               `json:"route,omitempty"`
	Transforms        []string             `json:"transforms,omitempty"`
	Reasoning         *ReasoningParams     `json:"reasoning,omitempty"`
	Usage             *UsageParams         `json:"usage,omitempty"`
	ExtraBody         map[string]any       `json:"-"`
	Plugins           []Plugin             `json:"plugins,omitempty"`
	ParallelToolCalls *bool                `json:"parallel_tool_calls,omitempty"`
	Provider          *ProviderPreferences `json:"provider,omitempty"`
	Metadata          map[string]string    `json:"metadata,omitempty"`
	Modalities        []string             `json:"modalities,omitempty"`
	ImageConfig       map[string]any       `json:"image_config,omitempty"`
	SessionID         string               `json:"session_id,omitempty"`
	Trace             *TraceMetadata       `json:"trace,omitempty"`
	Debug             *DebugOptions        `json:"debug,omitempty"`
}

func (ChatCompletionRequest) MarshalJSON

func (r ChatCompletionRequest) MarshalJSON() ([]byte, error)

type ChatCompletionResponse

type ChatCompletionResponse struct {
	ID                string   `json:"id"`
	Object            string   `json:"object"`
	Created           int64    `json:"created"`
	Model             string   `json:"model"`
	Choices           []Choice `json:"choices"`
	Usage             Usage    `json:"usage"`
	SystemFingerprint string   `json:"system_fingerprint,omitempty"`
}

type ChatCompletionStream

type ChatCompletionStream struct {
	*StreamReader
}

func (*ChatCompletionStream) Recv

type ChatCompletionStreamChoice

type ChatCompletionStreamChoice struct {
	Index              int                                 `json:"index"`
	Delta              ChatCompletionMessage               `json:"delta"`
	FinishReason       string                              `json:"finish_reason"`
	NativeFinishReason string                              `json:"native_finish_reason,omitempty"`
	Logprobs           *ChatCompletionStreamChoiceLogprobs `json:"logprobs,omitempty"`
}

type ChatCompletionStreamChoiceDelta

type ChatCompletionStreamChoiceDelta struct {
	Token   string  `json:"token"`
	LogProb float64 `json:"logprob"`
	Bytes   []byte  `json:"bytes,omitempty"`
}

type ChatCompletionStreamChoiceLogprobs

type ChatCompletionStreamChoiceLogprobs struct {
	Content []ChatCompletionStreamChoiceDelta `json:"content,omitempty"`
	Refusal []ChatCompletionStreamChoiceDelta `json:"refusal,omitempty"`
}

type ChatCompletionStreamResponse

type ChatCompletionStreamResponse struct {
	ID                string                       `json:"id"`
	Object            string                       `json:"object"`
	Created           int64                        `json:"created"`
	Model             string                       `json:"model"`
	Choices           []ChatCompletionStreamChoice `json:"choices"`
	SystemFingerprint string                       `json:"system_fingerprint,omitempty"`
	Usage             *Usage                       `json:"usage,omitempty"`
	Error             *APIError                    `json:"error,omitempty"`
}

type ChatCompletionTokenLogprob

type ChatCompletionTokenLogprob struct {
	Token       string                                 `json:"token"`
	LogProb     float64                                `json:"logprob"`
	Bytes       []byte                                 `json:"bytes,omitempty"`
	TopLogProbs []ChatCompletionTokenLogprobTopLogprob `json:"top_logprobs,omitempty"`
}

type ChatCompletionTokenLogprobTopLogprob

type ChatCompletionTokenLogprobTopLogprob struct {
	Token   string  `json:"token"`
	LogProb float64 `json:"logprob"`
	Bytes   []byte  `json:"bytes,omitempty"`
}

type Choice

type Choice struct {
	Index              int                           `json:"index"`
	Message            ChatCompletionMessage         `json:"message"`
	FinishReason       string                        `json:"finish_reason"`
	NativeFinishReason string                        `json:"native_finish_reason,omitempty"`
	Logprobs           *ChatCompletionChoiceLogprobs `json:"logprobs,omitempty"`
}

type Client

type Client struct {
	*official.OpenRouter
	// contains filtered or unexported fields
}

Client is a client for the OpenRouter API.

func NewClient

func NewClient(authToken string) *Client

NewClient creates a new OpenRouter API client.

func NewClientWithConfig

func NewClientWithConfig(config ClientConfig) *Client

NewClientWithConfig creates a new OpenRouter API client with a custom configuration.

func (*Client) BulkAssignKeys

func (c *Client) BulkAssignKeys(ctx context.Context, id string, req BulkAssignKeysRequest) error

func (*Client) BulkAssignMembers

func (c *Client) BulkAssignMembers(ctx context.Context, id string, req BulkAssignMembersRequest) error

func (*Client) BulkUnassignKeys

func (c *Client) BulkUnassignKeys(ctx context.Context, id string, req BulkAssignKeysRequest) error

func (*Client) BulkUnassignMembers

func (c *Client) BulkUnassignMembers(ctx context.Context, id string, req BulkAssignMembersRequest) error

func (*Client) CheckCredits deprecated

func (c *Client) CheckCredits(ctx context.Context) (*KeyData, error)

Deprecated: use GetCurrentKey. This method is kept as a compatibility alias.

func (*Client) CountModels

func (c *Client) CountModels(ctx context.Context) (int, error)

func (*Client) CreateAPIKey

func (c *Client) CreateAPIKey(ctx context.Context, req CreateAPIKeyRequest) (*ManagedAPIKey, error)

func (*Client) CreateAnthropicMessage

func (c *Client) CreateAnthropicMessage(ctx context.Context, req AnthropicMessageRequest) (*AnthropicMessageResponse, error)

func (*Client) CreateAnthropicMessageStream

func (c *Client) CreateAnthropicMessageStream(ctx context.Context, req AnthropicMessageRequest) (*AnthropicMessageStream, error)

func (*Client) CreateAuthCode

func (c *Client) CreateAuthCode(ctx context.Context, req CreateAuthCodeRequest) (*AuthCode, error)

func (*Client) CreateChatCompletion

func (c *Client) CreateChatCompletion(ctx context.Context, r ChatCompletionRequest) (*ChatCompletionResponse, error)

func (*Client) CreateChatCompletionStream

func (c *Client) CreateChatCompletionStream(ctx context.Context, r ChatCompletionRequest) (*ChatCompletionStream, error)

func (*Client) CreateCoinbaseCharge

func (c *Client) CreateCoinbaseCharge(ctx context.Context, req CoinbaseChargeRequest) (*CoinbaseCharge, error)

func (*Client) CreateEmbeddings

func (c *Client) CreateEmbeddings(ctx context.Context, req EmbeddingRequest) (*EmbeddingResponse, error)

func (*Client) CreateGuardrail

func (c *Client) CreateGuardrail(ctx context.Context, req GuardrailRequest) (*Guardrail, error)

func (*Client) CreateResponse

func (c *Client) CreateResponse(ctx context.Context, req ResponseRequest) (*Response, error)

func (*Client) CreateResponseStream

func (c *Client) CreateResponseStream(ctx context.Context, req ResponseRequest) (*ResponseStream, error)

func (*Client) DeleteAPIKey

func (c *Client) DeleteAPIKey(ctx context.Context, hash string) error

func (*Client) DeleteGuardrail

func (c *Client) DeleteGuardrail(ctx context.Context, id string) error

func (*Client) ExchangeAuthCodeForAPIKey

func (c *Client) ExchangeAuthCodeForAPIKey(ctx context.Context, req ExchangeAuthCodeRequest) (*ExchangeAuthCodeResponse, error)

func (*Client) GetAPIKey

func (c *Client) GetAPIKey(ctx context.Context, hash string) (*ManagedAPIKey, error)

func (*Client) GetCredits

func (c *Client) GetCredits(ctx context.Context) (*Credits, error)

func (*Client) GetCurrentKey

func (c *Client) GetCurrentKey(ctx context.Context) (*KeyData, error)

func (*Client) GetGeneration

func (c *Client) GetGeneration(ctx context.Context, id string) (*Generation, error)

func (*Client) GetGuardrail

func (c *Client) GetGuardrail(ctx context.Context, id string) (*Guardrail, error)

func (*Client) GetUserActivity

func (c *Client) GetUserActivity(ctx context.Context, params ActivityParams) ([]ActivityItem, error)

func (*Client) ListAPIKeys

func (c *Client) ListAPIKeys(ctx context.Context, params APIKeysListParams) ([]ManagedAPIKey, error)

func (*Client) ListEmbeddingsModels

func (c *Client) ListEmbeddingsModels(ctx context.Context) (*ModelsList, error)

func (*Client) ListGuardrailKeyAssignments

func (c *Client) ListGuardrailKeyAssignments(ctx context.Context, id string) ([]GuardrailAssignment, error)

func (*Client) ListGuardrailMemberAssignments

func (c *Client) ListGuardrailMemberAssignments(ctx context.Context, id string) ([]GuardrailAssignment, error)

func (*Client) ListGuardrails

func (c *Client) ListGuardrails(ctx context.Context) ([]Guardrail, error)

func (*Client) ListKeyAssignments

func (c *Client) ListKeyAssignments(ctx context.Context) ([]GuardrailAssignment, error)

func (*Client) ListMemberAssignments

func (c *Client) ListMemberAssignments(ctx context.Context) ([]GuardrailAssignment, error)

func (*Client) ListModelEndpoints

func (c *Client) ListModelEndpoints(ctx context.Context, author, slug string) (*ModelEndpoints, error)

func (*Client) ListModels

func (c *Client) ListModels(ctx context.Context) (*ModelsList, error)

func (*Client) ListModelsForUser

func (c *Client) ListModelsForUser(ctx context.Context) (*ModelsList, error)

func (*Client) ListModelsWithParams

func (c *Client) ListModelsWithParams(ctx context.Context, params ModelsListParams) (*ModelsList, error)

func (*Client) ListProviders

func (c *Client) ListProviders(ctx context.Context) (*ProvidersList, error)

func (*Client) ListZDREndpoints

func (c *Client) ListZDREndpoints(ctx context.Context) (*ZDREndpointsList, error)

func (*Client) UpdateAPIKey

func (c *Client) UpdateAPIKey(ctx context.Context, hash string, req UpdateAPIKeyRequest) (*ManagedAPIKey, error)

func (*Client) UpdateGuardrail

func (c *Client) UpdateGuardrail(ctx context.Context, id string, req GuardrailUpdateRequest) (*Guardrail, error)

type ClientConfig

type ClientConfig struct {
	AuthToken string
	BaseURL   string
	// Deprecated: this field is kept only for backward compatibility and is not sent, because the current public OpenRouter API does not define an organization header.
	OrgID          string
	HTTPClient     *http.Client
	SiteURL        string
	SiteName       string
	SiteCategories []string

	// Deprecated: use AuthToken instead.
	APIKey string
}

ClientConfig is a configuration of a client.

func DefaultConfig

func DefaultConfig(authToken string) ClientConfig

DefaultConfig returns a default configuration for the OpenRouter API client.

func (ClientConfig) String

func (ClientConfig) String() string

type CoinbaseCallData deprecated

type CoinbaseCallData = managementpkg.CoinbaseCallData

Deprecated: use management.CoinbaseCallData from package github.com/iamwavecut/gopenrouter/management.

type CoinbaseCharge deprecated

type CoinbaseCharge = managementpkg.CoinbaseCharge

Deprecated: use management.CoinbaseCharge from package github.com/iamwavecut/gopenrouter/management.

type CoinbaseChargeRequest deprecated

type CoinbaseChargeRequest = managementpkg.CoinbaseChargeRequest

Deprecated: use management.CoinbaseChargeRequest from package github.com/iamwavecut/gopenrouter/management.

type CoinbaseChargeResponse deprecated

type CoinbaseChargeResponse = managementpkg.CoinbaseChargeResponse

Deprecated: use management.CoinbaseChargeResponse from package github.com/iamwavecut/gopenrouter/management.

type CoinbaseTransferIntent deprecated

type CoinbaseTransferIntent = managementpkg.CoinbaseTransferIntent

Deprecated: use management.CoinbaseTransferIntent from package github.com/iamwavecut/gopenrouter/management.

type CoinbaseTransferMeta deprecated

type CoinbaseTransferMeta = managementpkg.CoinbaseTransferMeta

Deprecated: use management.CoinbaseTransferMeta from package github.com/iamwavecut/gopenrouter/management.

type CoinbaseWeb3Data deprecated

type CoinbaseWeb3Data = managementpkg.CoinbaseWeb3Data

Deprecated: use management.CoinbaseWeb3Data from package github.com/iamwavecut/gopenrouter/management.

type CostDetails

type CostDetails struct {
	UpstreamInferenceCost       float64 `json:"upstream_inference_cost,omitempty"`
	UpstreamInferenceInputCost  float64 `json:"upstream_inference_input_cost,omitempty"`
	UpstreamInferenceOutputCost float64 `json:"upstream_inference_output_cost,omitempty"`
}

type CreateAPIKeyRequest deprecated

type CreateAPIKeyRequest = managementpkg.CreateAPIKeyRequest

Deprecated: use management.CreateAPIKeyRequest from package github.com/iamwavecut/gopenrouter/management.

type CreateAuthCodeRequest deprecated

type CreateAuthCodeRequest = oauthpkg.CreateAuthCodeRequest

Deprecated: use oauth.CreateAuthCodeRequest from package github.com/iamwavecut/gopenrouter/oauth.

type CreateAuthCodeResponse deprecated

type CreateAuthCodeResponse = oauthpkg.CreateAuthCodeResponse

Deprecated: use oauth.CreateAuthCodeResponse from package github.com/iamwavecut/gopenrouter/oauth.

type Credits deprecated

type Credits = managementpkg.Credits

Deprecated: use management.Credits from package github.com/iamwavecut/gopenrouter/management.

type CreditsResponse deprecated

type CreditsResponse = managementpkg.CreditsResponse

Deprecated: use management.CreditsResponse from package github.com/iamwavecut/gopenrouter/management.

type DataCollection deprecated

type DataCollection = shared.DataCollection

Deprecated: use shared.DataCollection from package github.com/iamwavecut/gopenrouter/shared.

type DebugOptions deprecated

type DebugOptions = shared.DebugOptions

Deprecated: use shared.DebugOptions from package github.com/iamwavecut/gopenrouter/shared.

type DefaultParameters deprecated

type DefaultParameters = catalog.DefaultParameters

Deprecated: use catalog.DefaultParameters from package github.com/iamwavecut/gopenrouter/catalog.

type EmbeddingDatum deprecated

type EmbeddingDatum = embeddingspkg.Datum

Deprecated: use embeddings.Datum from package github.com/iamwavecut/gopenrouter/embeddings.

type EmbeddingInputPart deprecated

type EmbeddingInputPart = embeddingspkg.InputPart

Deprecated: use embeddings.InputPart from package github.com/iamwavecut/gopenrouter/embeddings.

type EmbeddingMultimodalInput deprecated

type EmbeddingMultimodalInput = embeddingspkg.MultimodalInput

Deprecated: use embeddings.MultimodalInput from package github.com/iamwavecut/gopenrouter/embeddings.

type EmbeddingRequest deprecated

type EmbeddingRequest = embeddingspkg.Request

Deprecated: use embeddings.Request from package github.com/iamwavecut/gopenrouter/embeddings.

type EmbeddingResponse deprecated

type EmbeddingResponse = embeddingspkg.Response

Deprecated: use embeddings.Response from package github.com/iamwavecut/gopenrouter/embeddings.

type EmbeddingUsage deprecated

type EmbeddingUsage = embeddingspkg.Usage

Deprecated: use embeddings.Usage from package github.com/iamwavecut/gopenrouter/embeddings.

type EmbeddingValue deprecated

type EmbeddingValue = embeddingspkg.Value

Deprecated: use embeddings.Value from package github.com/iamwavecut/gopenrouter/embeddings.

type ErrorResponse deprecated

type ErrorResponse = shared.ErrorResponse

Deprecated: use shared.ErrorResponse from package github.com/iamwavecut/gopenrouter/shared.

type ExchangeAuthCodeRequest deprecated

type ExchangeAuthCodeRequest = oauthpkg.ExchangeAuthCodeRequest

Deprecated: use oauth.ExchangeAuthCodeRequest from package github.com/iamwavecut/gopenrouter/oauth.

type ExchangeAuthCodeResponse deprecated

type ExchangeAuthCodeResponse = oauthpkg.ExchangeAuthCodeResponse

Deprecated: use oauth.ExchangeAuthCodeResponse from package github.com/iamwavecut/gopenrouter/oauth.

type File deprecated

type File = shared.File

Deprecated: use shared.File from package github.com/iamwavecut/gopenrouter/shared.

type FileParserConfig deprecated

type FileParserConfig = shared.FileParserConfig

Deprecated: use shared.FileParserConfig from package github.com/iamwavecut/gopenrouter/shared.

type Function

type Function struct {
	Name        string `json:"name"`
	Description string `json:"description,omitempty"`
	Parameters  any    `json:"parameters,omitempty"`
	Arguments   string `json:"arguments,omitempty"`
}

type GeneratedImage deprecated

type GeneratedImage = shared.GeneratedImage

Deprecated: use shared.GeneratedImage from package github.com/iamwavecut/gopenrouter/shared.

type Generation

type Generation struct {
	ID                          string                       `json:"id"`
	UpstreamID                  string                       `json:"upstream_id,omitempty"`
	TotalCost                   float64                      `json:"total_cost,omitempty"`
	CacheDiscount               float64                      `json:"cache_discount,omitempty"`
	UpstreamInferenceCost       float64                      `json:"upstream_inference_cost,omitempty"`
	CreatedAt                   string                       `json:"created_at,omitempty"`
	Model                       string                       `json:"model,omitempty"`
	AppID                       int                          `json:"app_id,omitempty"`
	Streamed                    *bool                        `json:"streamed,omitempty"`
	Cancelled                   *bool                        `json:"cancelled,omitempty"`
	ProviderName                string                       `json:"provider_name,omitempty"`
	Latency                     *float64                     `json:"latency,omitempty"`
	ModerationLatency           *float64                     `json:"moderation_latency,omitempty"`
	GenerationTime              *float64                     `json:"generation_time,omitempty"`
	FinishReason                string                       `json:"finish_reason,omitempty"`
	NativeFinishReason          string                       `json:"native_finish_reason,omitempty"`
	PromptTokens                int                          `json:"tokens_prompt,omitempty"`
	CompletionTokens            int                          `json:"tokens_completion,omitempty"`
	NativePromptTokens          int                          `json:"native_tokens_prompt,omitempty"`
	NativeCompletionTokens      int                          `json:"native_tokens_completion,omitempty"`
	NativeCompletionImageTokens int                          `json:"native_tokens_completion_images,omitempty"`
	NativeReasoningTokens       int                          `json:"native_tokens_reasoning,omitempty"`
	NativeCachedTokens          int                          `json:"native_tokens_cached,omitempty"`
	NumMediaPrompt              int                          `json:"num_media_prompt,omitempty"`
	NumInputAudioPrompt         int                          `json:"num_input_audio_prompt,omitempty"`
	NumMediaCompletion          int                          `json:"num_media_completion,omitempty"`
	NumSearchResults            int                          `json:"num_search_results,omitempty"`
	Origin                      string                       `json:"origin,omitempty"`
	Usage                       float64                      `json:"usage,omitempty"`
	IsBYOK                      bool                         `json:"is_byok,omitempty"`
	ExternalUser                string                       `json:"external_user,omitempty"`
	APIType                     string                       `json:"api_type,omitempty"`
	Router                      string                       `json:"router,omitempty"`
	ProviderResponses           []GenerationProviderResponse `json:"provider_responses,omitempty"`
}

type GenerationProviderResponse

type GenerationProviderResponse struct {
	ID             string   `json:"id,omitempty"`
	EndpointID     string   `json:"endpoint_id,omitempty"`
	ModelPermaslug string   `json:"model_permaslug,omitempty"`
	ProviderName   string   `json:"provider_name,omitempty"`
	Status         *int     `json:"status,omitempty"`
	Latency        *float64 `json:"latency,omitempty"`
	IsBYOK         *bool    `json:"is_byok,omitempty"`
}

type GenerationResponse

type GenerationResponse struct {
	Data Generation `json:"data"`
}

type Guardrail deprecated

type Guardrail = managementpkg.Guardrail

Deprecated: use management.Guardrail from package github.com/iamwavecut/gopenrouter/management.

type GuardrailAssignment deprecated

type GuardrailAssignment = managementpkg.GuardrailAssignment

Deprecated: use management.GuardrailAssignment from package github.com/iamwavecut/gopenrouter/management.

type GuardrailAssignmentsResponse deprecated

type GuardrailAssignmentsResponse = managementpkg.GuardrailAssignmentsResponse

Deprecated: use management.GuardrailAssignmentsResponse from package github.com/iamwavecut/gopenrouter/management.

type GuardrailRequest deprecated

type GuardrailRequest = managementpkg.GuardrailRequest

Deprecated: use management.GuardrailRequest from package github.com/iamwavecut/gopenrouter/management.

type GuardrailResponse deprecated

type GuardrailResponse = managementpkg.GuardrailResponse

Deprecated: use management.GuardrailResponse from package github.com/iamwavecut/gopenrouter/management.

type GuardrailUpdateRequest deprecated

type GuardrailUpdateRequest = managementpkg.GuardrailUpdateRequest

Deprecated: use management.GuardrailUpdateRequest from package github.com/iamwavecut/gopenrouter/management.

type GuardrailsResponse deprecated

type GuardrailsResponse = managementpkg.GuardrailsResponse

Deprecated: use management.GuardrailsResponse from package github.com/iamwavecut/gopenrouter/management.

type ImageURL deprecated

type ImageURL = shared.ImageURL

Deprecated: use shared.ImageURL from package github.com/iamwavecut/gopenrouter/shared.

type InputAudio deprecated

type InputAudio = shared.InputAudio

Deprecated: use shared.InputAudio from package github.com/iamwavecut/gopenrouter/shared.

type JSONSchema deprecated

type JSONSchema = shared.JSONSchema

Deprecated: use shared.JSONSchema from package github.com/iamwavecut/gopenrouter/shared.

type KeyCheckResponse deprecated

type KeyCheckResponse = managementpkg.KeyCheckResponse

Deprecated: use management.KeyCheckResponse from package github.com/iamwavecut/gopenrouter/management.

type KeyData deprecated

type KeyData = managementpkg.KeyData

Deprecated: use management.KeyData from package github.com/iamwavecut/gopenrouter/management.

type LatencyCutoffs deprecated

type LatencyCutoffs = shared.LatencyCutoffs

Deprecated: use shared.LatencyCutoffs from package github.com/iamwavecut/gopenrouter/shared.

type LatencyPreference deprecated

type LatencyPreference = shared.LatencyPreference

Deprecated: use shared.LatencyPreference from package github.com/iamwavecut/gopenrouter/shared.

type LegacyRateLimit deprecated

type LegacyRateLimit = managementpkg.LegacyRateLimit

Deprecated: use management.LegacyRateLimit from package github.com/iamwavecut/gopenrouter/management.

type ManagedAPIKey deprecated

type ManagedAPIKey = managementpkg.ManagedAPIKey

Deprecated: use management.ManagedAPIKey from package github.com/iamwavecut/gopenrouter/management.

type Model deprecated

type Model = catalog.Model

Deprecated: use catalog.Model from package github.com/iamwavecut/gopenrouter/catalog.

type ModelArchitecture deprecated

type ModelArchitecture = catalog.ModelArchitecture

Deprecated: use catalog.ModelArchitecture from package github.com/iamwavecut/gopenrouter/catalog.

type ModelEndpoints deprecated

type ModelEndpoints = catalog.ModelEndpoints

Deprecated: use catalog.ModelEndpoints from package github.com/iamwavecut/gopenrouter/catalog.

type ModelEndpointsResponse deprecated

type ModelEndpointsResponse = catalog.ModelEndpointsResponse

Deprecated: use catalog.ModelEndpointsResponse from package github.com/iamwavecut/gopenrouter/catalog.

type ModelsCountResponse deprecated

type ModelsCountResponse = catalog.ModelsCountResponse

Deprecated: use catalog.ModelsCountResponse from package github.com/iamwavecut/gopenrouter/catalog.

type ModelsList deprecated

type ModelsList = catalog.ModelsList

Deprecated: use catalog.ModelsList from package github.com/iamwavecut/gopenrouter/catalog.

type ModelsListParams deprecated

type ModelsListParams = catalog.ModelsListParams

Deprecated: use catalog.ModelsListParams from package github.com/iamwavecut/gopenrouter/catalog.

type PDFEngine deprecated

type PDFEngine = shared.PDFEngine

Deprecated: use shared.PDFEngine from package github.com/iamwavecut/gopenrouter/shared.

type PDFPlugin deprecated

type PDFPlugin = shared.PDFPlugin

Deprecated: use shared.PDFPlugin from package github.com/iamwavecut/gopenrouter/shared.

type PerRequestLimits deprecated

type PerRequestLimits = catalog.PerRequestLimits

Deprecated: use catalog.PerRequestLimits from package github.com/iamwavecut/gopenrouter/catalog.

type PercentileStats deprecated

type PercentileStats = shared.PercentileStats

Deprecated: use shared.PercentileStats from package github.com/iamwavecut/gopenrouter/shared.

type Plugin deprecated

type Plugin = shared.Plugin

Deprecated: use shared.Plugin from package github.com/iamwavecut/gopenrouter/shared.

type PluginID deprecated

type PluginID = shared.PluginID

Deprecated: use shared.PluginID from package github.com/iamwavecut/gopenrouter/shared.

type Prediction

type Prediction struct {
	Type    string `json:"type"`
	Content string `json:"content"`
}

type Pricing deprecated

type Pricing = catalog.Pricing

Deprecated: use catalog.Pricing from package github.com/iamwavecut/gopenrouter/catalog.

type Provider deprecated

type Provider = shared.Provider

Deprecated: use shared.Provider from package github.com/iamwavecut/gopenrouter/shared.

type ProviderError deprecated

type ProviderError = shared.ProviderError

Deprecated: use shared.ProviderError from package github.com/iamwavecut/gopenrouter/shared.

type ProviderInfo deprecated

type ProviderInfo = catalog.ProviderInfo

Deprecated: use catalog.ProviderInfo from package github.com/iamwavecut/gopenrouter/catalog.

type ProviderMaxPrice deprecated

type ProviderMaxPrice = shared.ProviderMaxPrice

Deprecated: use shared.ProviderMaxPrice from package github.com/iamwavecut/gopenrouter/shared.

type ProviderPreferences deprecated

type ProviderPreferences = shared.ProviderPreferences

Deprecated: use shared.ProviderPreferences from package github.com/iamwavecut/gopenrouter/shared.

type ProviderSort deprecated

type ProviderSort = shared.ProviderSort

Deprecated: use shared.ProviderSort from package github.com/iamwavecut/gopenrouter/shared.

type ProviderSortConfig deprecated

type ProviderSortConfig = shared.ProviderSortConfig

Deprecated: use shared.ProviderSortConfig from package github.com/iamwavecut/gopenrouter/shared.

type ProviderSortPartition deprecated

type ProviderSortPartition = shared.ProviderSortPartition

Deprecated: use shared.ProviderSortPartition from package github.com/iamwavecut/gopenrouter/shared.

type ProviderSortPreference deprecated

type ProviderSortPreference = shared.ProviderSortPreference

Deprecated: use shared.ProviderSortPreference from package github.com/iamwavecut/gopenrouter/shared.

type ProvidersList deprecated

type ProvidersList = catalog.ProvidersList

Deprecated: use catalog.ProvidersList from package github.com/iamwavecut/gopenrouter/catalog.

type PublicEndpoint deprecated

type PublicEndpoint = catalog.PublicEndpoint

Deprecated: use catalog.PublicEndpoint from package github.com/iamwavecut/gopenrouter/catalog.

type Quantization deprecated

type Quantization = shared.Quantization

Deprecated: use shared.Quantization from package github.com/iamwavecut/gopenrouter/shared.

type ReasoningDetail

type ReasoningDetail struct {
	Type      string `json:"type"`
	Summary   string `json:"summary,omitempty"`
	Data      string `json:"data,omitempty"`
	Text      string `json:"text,omitempty"`
	Signature string `json:"signature,omitempty"`
	ID        string `json:"id,omitempty"`
	Format    string `json:"format,omitempty"`
	Index     *int   `json:"index,omitempty"`

	Encrypted string `json:"-"`
}

func (ReasoningDetail) MarshalJSON

func (r ReasoningDetail) MarshalJSON() ([]byte, error)

func (*ReasoningDetail) UnmarshalJSON

func (r *ReasoningDetail) UnmarshalJSON(data []byte) error

type ReasoningEffort

type ReasoningEffort string
const (
	ReasoningEffortXHigh   ReasoningEffort = "xhigh"
	ReasoningEffortHigh    ReasoningEffort = "high"
	ReasoningEffortMedium  ReasoningEffort = "medium"
	ReasoningEffortLow     ReasoningEffort = "low"
	ReasoningEffortMinimal ReasoningEffort = "minimal"
	ReasoningEffortNone    ReasoningEffort = "none"
)

type ReasoningParams

type ReasoningParams struct {
	Effort  ReasoningEffort           `json:"effort,omitempty"`
	Summary ReasoningSummaryVerbosity `json:"summary,omitempty"`
	// Deprecated: retained only as a legacy compatibility field.
	Exclude bool `json:"exclude,omitempty"`
	// Deprecated: retained only as a legacy compatibility field.
	MaxTokens int `json:"max_tokens,omitempty"`
}

type ReasoningSummaryVerbosity

type ReasoningSummaryVerbosity string
const (
	ReasoningSummaryAuto     ReasoningSummaryVerbosity = "auto"
	ReasoningSummaryConcise  ReasoningSummaryVerbosity = "concise"
	ReasoningSummaryDetailed ReasoningSummaryVerbosity = "detailed"
)

type RequestError deprecated

type RequestError = shared.RequestError

Deprecated: use shared.RequestError from package github.com/iamwavecut/gopenrouter/shared.

type Response deprecated

type Response = responsespkg.Response

Deprecated: use responses.Response from package github.com/iamwavecut/gopenrouter/responses.

type ResponseContentPart deprecated

type ResponseContentPart = responsespkg.ContentPart

Deprecated: use responses.ContentPart from package github.com/iamwavecut/gopenrouter/responses.

type ResponseFormat deprecated

type ResponseFormat = shared.ResponseFormat

Deprecated: use shared.ResponseFormat from package github.com/iamwavecut/gopenrouter/shared.

type ResponseOutputItem deprecated

type ResponseOutputItem = responsespkg.OutputItem

Deprecated: use responses.OutputItem from package github.com/iamwavecut/gopenrouter/responses.

type ResponseReasoningConfig deprecated

type ResponseReasoningConfig = responsespkg.ReasoningConfig

Deprecated: use responses.ReasoningConfig from package github.com/iamwavecut/gopenrouter/responses.

type ResponseRequest deprecated

type ResponseRequest = responsespkg.Request

Deprecated: use responses.Request from package github.com/iamwavecut/gopenrouter/responses.

type ResponseStream deprecated

type ResponseStream = responsespkg.Stream

Deprecated: use responses.Stream from package github.com/iamwavecut/gopenrouter/responses.

type ResponseStreamEvent deprecated

type ResponseStreamEvent = responsespkg.StreamEvent

Deprecated: use responses.StreamEvent from package github.com/iamwavecut/gopenrouter/responses.

type ResponseTextConfig deprecated

type ResponseTextConfig = responsespkg.TextConfig

Deprecated: use responses.TextConfig from package github.com/iamwavecut/gopenrouter/responses.

type ResponseTool deprecated

type ResponseTool = responsespkg.Tool

Deprecated: use responses.Tool from package github.com/iamwavecut/gopenrouter/responses.

type ResponseUsage deprecated

type ResponseUsage = responsespkg.Usage

Deprecated: use responses.Usage from package github.com/iamwavecut/gopenrouter/responses.

type SSEEvent

type SSEEvent struct {
	Event string
	Data  []byte
}

type SSEReader

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

func (*SSEReader) RecvEvent

func (s *SSEReader) RecvEvent() (SSEEvent, error)

type SearchContextSize deprecated

type SearchContextSize = shared.SearchContextSize

Deprecated: use shared.SearchContextSize from package github.com/iamwavecut/gopenrouter/shared.

type ServerToolUse

type ServerToolUse struct {
	WebSearchRequests int `json:"web_search_requests,omitempty"`
}

type StreamOptions

type StreamOptions struct {
	IncludeUsage bool `json:"include_usage,omitempty"`
}

type StreamReader

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

func (*StreamReader) Close

func (s *StreamReader) Close()

func (*StreamReader) Recv

func (s *StreamReader) Recv() ([]byte, error)

type ThroughputCutoffs deprecated

type ThroughputCutoffs = shared.ThroughputCutoffs

Deprecated: use shared.ThroughputCutoffs from package github.com/iamwavecut/gopenrouter/shared.

type ThroughputPreference deprecated

type ThroughputPreference = shared.ThroughputPreference

Deprecated: use shared.ThroughputPreference from package github.com/iamwavecut/gopenrouter/shared.

type TokensDetails

type TokensDetails struct {
	CachedTokens             int `json:"cached_tokens,omitempty"`
	CacheWriteTokens         int `json:"cache_write_tokens,omitempty"`
	ReasoningTokens          int `json:"reasoning_tokens,omitempty"`
	AudioTokens              int `json:"audio_tokens,omitempty"`
	VideoTokens              int `json:"video_tokens,omitempty"`
	AcceptedPredictionTokens int `json:"accepted_prediction_tokens,omitempty"`
	RejectedPredictionTokens int `json:"rejected_prediction_tokens,omitempty"`
}

type Tool

type Tool struct {
	Type     string   `json:"type"`
	Function Function `json:"function"`
}

type ToolCall

type ToolCall struct {
	Index    int      `json:"index,omitempty"`
	ID       string   `json:"id,omitempty"`
	Type     string   `json:"type,omitempty"`
	Function Function `json:"function"`
}

type TopProviderInfo deprecated

type TopProviderInfo = catalog.TopProviderInfo

Deprecated: use catalog.TopProviderInfo from package github.com/iamwavecut/gopenrouter/catalog.

type TraceMetadata deprecated

type TraceMetadata = shared.TraceMetadata

Deprecated: use shared.TraceMetadata from package github.com/iamwavecut/gopenrouter/shared.

type UpdateAPIKeyRequest deprecated

type UpdateAPIKeyRequest = managementpkg.UpdateAPIKeyRequest

Deprecated: use management.UpdateAPIKeyRequest from package github.com/iamwavecut/gopenrouter/management.

type Usage

type Usage struct {
	PromptTokens            int            `json:"prompt_tokens"`
	CompletionTokens        int            `json:"completion_tokens"`
	TotalTokens             int            `json:"total_tokens"`
	Cost                    float64        `json:"cost,omitempty"`
	IsBYOK                  *bool          `json:"is_byok,omitempty"`
	ImageTokens             int            `json:"image_tokens,omitempty"`
	CostDetails             *CostDetails   `json:"cost_details,omitempty"`
	ServerToolUse           *ServerToolUse `json:"server_tool_use,omitempty"`
	PromptTokensDetails     *TokensDetails `json:"prompt_tokens_details,omitempty"`
	CompletionTokensDetails *TokensDetails `json:"completion_tokens_details,omitempty"`
}

type UsageParams

type UsageParams struct {
	Include bool `json:"include"`
}

type VideoInput deprecated

type VideoInput = shared.VideoInput

Deprecated: use shared.VideoInput from package github.com/iamwavecut/gopenrouter/shared.

type WebSearchOptions deprecated

type WebSearchOptions = shared.WebSearchOptions

Deprecated: use shared.WebSearchOptions from package github.com/iamwavecut/gopenrouter/shared.

type ZDREndpointsList deprecated

type ZDREndpointsList = catalog.ZDREndpointsList

Deprecated: use catalog.ZDREndpointsList from package github.com/iamwavecut/gopenrouter/catalog.

Directories

Path Synopsis
examples
chat command
chat_caching command
chat_extra_body command
chat_reasoning command
chat_stream command
chat_vision command
check_credits command
embeddings command
get_generation command
list_models command
logprobs command
responses command
stream_cancel command
tool_call_loop command
internal
sse

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL