Documentation
¶
Overview ¶
Package openrouter provides an OpenAI-compatible API client with additional OpenRouter features.
The OpenRouter API offers OpenAI-compatible endpoints with additional features like model routing, provider selection, and unified billing.
This SDK is in beta. Pin to a specific module version to avoid unexpected breaking changes:
go get github.com/OpenRouterTeam/go-sdk@v0.7.140
For full API documentation, visit: https://openrouter.ai/docs/client-sdks/go/overview
Authentication:
import (
"context"
openrouter "github.com/OpenRouterTeam/go-sdk"
"github.com/OpenRouterTeam/go-sdk/models/components"
)
sdk := openrouter.New(
openrouter.WithSecurity("your-api-key"),
)
The API key can also be read from the OPENROUTER_API_KEY environment variable when using New without WithSecurity.
For license information, see the LICENSE file at the repository root.
Examples:
Basic chat completion:
ctx := context.Background()
res, err := sdk.Chat.Send(ctx, components.ChatRequest{
Model: openrouter.Pointer("openai/gpt-4o"),
Messages: []components.ChatMessages{
components.CreateChatMessagesUser(
components.ChatUserMessage{
Role: components.ChatUserMessageRoleUser,
Content: components.CreateChatUserMessageContentStr("Hello!"),
},
),
},
}, nil)
Example ¶
Example demonstrates basic usage of the OpenRouter SDK for chat completions.
package main
import (
"context"
"fmt"
"log"
"os"
openrouter "github.com/OpenRouterTeam/go-sdk"
"github.com/OpenRouterTeam/go-sdk/models/components"
"github.com/OpenRouterTeam/go-sdk/optionalnullable"
)
func main() {
ctx := context.Background()
sdk := openrouter.New(
openrouter.WithSecurity(os.Getenv("OPENROUTER_API_KEY")),
)
res, err := sdk.Chat.Send(ctx, components.ChatRequest{
Model: openrouter.Pointer("openai/gpt-4o"),
Messages: []components.ChatMessages{
components.CreateChatMessagesUser(
components.ChatUserMessage{
Role: components.ChatUserMessageRoleUser,
Content: components.CreateChatUserMessageContentStr(
"Hello, how are you?",
),
},
),
},
Temperature: optionalnullable.From(openrouter.Pointer(0.7)),
}, nil)
if err != nil {
log.Fatal(err)
}
if res != nil && res.ChatResult != nil && len(res.ChatResult.Choices) > 0 {
fmt.Printf("Response received with %d choices\n", len(res.ChatResult.Choices))
}
}
Output:
Example (ChatWithMaxTokens) ¶
Example_chatWithMaxTokens demonstrates sending a chat request with max tokens limit.
package main
import (
"context"
"fmt"
"log"
"os"
openrouter "github.com/OpenRouterTeam/go-sdk"
"github.com/OpenRouterTeam/go-sdk/models/components"
"github.com/OpenRouterTeam/go-sdk/optionalnullable"
)
func main() {
ctx := context.Background()
sdk := openrouter.New(
openrouter.WithSecurity(os.Getenv("OPENROUTER_API_KEY")),
)
res, err := sdk.Chat.Send(ctx, components.ChatRequest{
Model: openrouter.Pointer("anthropic/claude-3-sonnet"),
Messages: []components.ChatMessages{
components.CreateChatMessagesUser(
components.ChatUserMessage{
Role: components.ChatUserMessageRoleUser,
Content: components.CreateChatUserMessageContentStr("Say hello"),
},
),
},
MaxTokens: optionalnullable.From(openrouter.Pointer(int64(100))),
}, nil)
if err != nil {
log.Fatal(err)
}
if res != nil && res.ChatResult != nil {
fmt.Printf("Model used: %s\n", res.ChatResult.Model)
}
}
Output:
Example (GenerateEmbedding) ¶
Example_generateEmbedding demonstrates generating text embeddings.
package main
import (
"context"
"fmt"
"log"
"os"
openrouter "github.com/OpenRouterTeam/go-sdk"
"github.com/OpenRouterTeam/go-sdk/models/operations"
)
func main() {
ctx := context.Background()
sdk := openrouter.New(
openrouter.WithSecurity(os.Getenv("OPENROUTER_API_KEY")),
)
res, err := sdk.Embeddings.Generate(ctx, operations.CreateEmbeddingsRequest{
Model: "openai/text-embedding-ada-002",
Input: operations.CreateInputUnionStr("The quick brown fox jumps over the lazy dog"),
}, nil)
if err != nil {
log.Fatal(err)
}
if res != nil && res.CreateEmbeddingsResponseBody != nil && len(res.CreateEmbeddingsResponseBody.Data) > 0 {
embedding := res.CreateEmbeddingsResponseBody.Data[0].GetEmbedding()
if embedding.Type == operations.EmbeddingTypeArrayOfNumber {
fmt.Printf("Vector dimensions: %d\n", len(embedding.ArrayOfNumber))
}
}
}
Output:
Example (GetModel) ¶
Example_getModel demonstrates retrieving information about a specific model.
package main
import (
"context"
"fmt"
"log"
"os"
openrouter "github.com/OpenRouterTeam/go-sdk"
)
func main() {
ctx := context.Background()
sdk := openrouter.New(
openrouter.WithSecurity(os.Getenv("OPENROUTER_API_KEY")),
)
res, err := sdk.Models.Get(ctx, "openai", "gpt-4o")
if err != nil {
log.Fatal(err)
}
if res != nil {
fmt.Printf("Model: %s\n", res.Data.Name)
fmt.Printf("ID: %s\n", res.Data.ID)
}
}
Output:
Example (ListModels) ¶
Example_listModels demonstrates listing available models.
package main
import (
"context"
"fmt"
"log"
"os"
openrouter "github.com/OpenRouterTeam/go-sdk"
)
func main() {
ctx := context.Background()
sdk := openrouter.New(
openrouter.WithSecurity(os.Getenv("OPENROUTER_API_KEY")),
)
res, err := sdk.Models.List(ctx, nil)
if err != nil {
log.Fatal(err)
}
if res != nil {
fmt.Println("Successfully fetched models")
}
}
Output:
Example (ListProviders) ¶
Example_listProviders demonstrates listing available providers.
package main
import (
"context"
"fmt"
"log"
"os"
openrouter "github.com/OpenRouterTeam/go-sdk"
)
func main() {
ctx := context.Background()
sdk := openrouter.New(
openrouter.WithSecurity(os.Getenv("OPENROUTER_API_KEY")),
)
res, err := sdk.Providers.List(ctx, nil)
if err != nil {
log.Fatal(err)
}
if res != nil && len(res.Data) > 0 {
fmt.Printf("Found %d providers\n", len(res.Data))
for i, provider := range res.Data {
if i < 3 {
fmt.Printf("- %s\n", provider.Name)
}
}
}
}
Output:
Example (StreamChat) ¶
Example_streamChat demonstrates streaming chat responses.
package main
import (
"context"
"fmt"
"log"
"os"
openrouter "github.com/OpenRouterTeam/go-sdk"
"github.com/OpenRouterTeam/go-sdk/models/components"
)
func main() {
ctx := context.Background()
sdk := openrouter.New(
openrouter.WithSecurity(os.Getenv("OPENROUTER_API_KEY")),
)
res, err := sdk.Chat.Send(ctx, components.ChatRequest{
Model: openrouter.Pointer("openai/gpt-4o-mini"),
Messages: []components.ChatMessages{
components.CreateChatMessagesUser(
components.ChatUserMessage{
Role: components.ChatUserMessageRoleUser,
Content: components.CreateChatUserMessageContentStr(
"Count from 1 to 3, one number per line.",
),
},
),
},
Stream: openrouter.Pointer(true),
}, nil)
if err != nil {
log.Fatal(err)
}
if res == nil || res.EventStream == nil {
log.Fatal("expected streaming response")
}
stream := res.EventStream
defer stream.Close()
for stream.Next() {
chunk := stream.Value()
if chunk == nil {
continue
}
for _, choice := range chunk.Data.Choices {
if text, ok := choice.Delta.Content.Get(); ok && text != nil {
fmt.Print(*text)
}
}
}
fmt.Println()
if err := stream.Err(); err != nil {
log.Fatal(err)
}
}
Output:
Index ¶
- Constants
- Variables
- func Bool(b bool) *bool
- func Float32(f float32) *float32
- func Float64(f float64) *float64
- func Int(i int) *int
- func Int64(i int64) *int64
- func Pointer[T any](v T) *T
- func String(s string) *string
- type APIKeys
- func (s *APIKeys) Create(ctx context.Context, request operations.CreateKeysRequest, ...) (*operations.CreateKeysResponse, error)
- func (s *APIKeys) Delete(ctx context.Context, hash string, opts ...operations.Option) (*operations.DeleteKeysResponse, error)
- func (s *APIKeys) Get(ctx context.Context, hash string, opts ...operations.Option) (*operations.GetKeyResponse, error)
- func (s *APIKeys) GetCurrentKeyMetadata(ctx context.Context, opts ...operations.Option) (*operations.GetCurrentKeyResponse, error)
- func (s *APIKeys) List(ctx context.Context, includeDisabled *bool, ...) (*operations.ListResponse, error)
- func (s *APIKeys) Update(ctx context.Context, hash string, requestBody operations.UpdateKeysRequestBody, ...) (*operations.UpdateKeysResponse, error)
- type Analytics
- func (s *Analytics) GetAnalyticsMeta(ctx context.Context, opts ...operations.Option) (*operations.GetAnalyticsMetaResponse, error)
- func (s *Analytics) GetUserActivity(ctx context.Context, date *string, apiKeyHash *string, userID *string, ...) (*components.ActivityResponse, error)
- func (s *Analytics) QueryAnalytics(ctx context.Context, request operations.QueryAnalyticsRequest, ...) (*operations.QueryAnalyticsResponse, error)
- type BYOK
- func (s *BYOK) Create(ctx context.Context, request components.CreateBYOKKeyRequest, ...) (*components.CreateBYOKKeyResponse, error)
- func (s *BYOK) Delete(ctx context.Context, id string, opts ...operations.Option) (*components.DeleteBYOKKeyResponse, error)
- func (s *BYOK) Get(ctx context.Context, id string, opts ...operations.Option) (*components.GetBYOKKeyResponse, error)
- func (s *BYOK) List(ctx context.Context, offset optionalnullable.OptionalNullable[int64], ...) (*operations.ListBYOKKeysResponse, error)
- func (s *BYOK) Update(ctx context.Context, id string, ...) (*components.UpdateBYOKKeyResponse, error)
- type Benchmarks
- type Beta
- type BetaResponses
- type Chat
- type Classifications
- type Containers
- func (s *Containers) DownloadContainerFileContent(ctx context.Context, containerID string, fileID string, ...) (io.ReadCloser, error)
- func (s *Containers) GetContainerFile(ctx context.Context, containerID string, fileID string, ...) (*components.ContainerFile, error)
- func (s *Containers) ListContainerFiles(ctx context.Context, containerID string, limit *int64, after *string, ...) (*components.ContainerFileListResponse, error)
- func (s *Containers) PromoteContainerFile(ctx context.Context, containerID string, fileID string, ...) (*components.FileResponse, error)
- type Credits
- type Datasets
- func (s *Datasets) GetAppRankings(ctx context.Context, request *operations.GetAppRankingsRequest, ...) (*operations.GetAppRankingsResponse, error)
- func (s *Datasets) GetRankingsDaily(ctx context.Context, request *operations.GetRankingsDailyRequest, ...) (*components.RankingsDailyResponse, error)
- func (s *Datasets) GetSessionCost(ctx context.Context, request *operations.GetSessionCostRequest, ...) (*operations.GetSessionCostResponse, error)
- type Embeddings
- func (s *Embeddings) Generate(ctx context.Context, request operations.CreateEmbeddingsRequest, ...) (*operations.CreateEmbeddingsResponse, error)
- func (s *Embeddings) ListModels(ctx context.Context, offset optionalnullable.OptionalNullable[int64], ...) (*operations.ListEmbeddingsModelsResponse, error)
- type Endpoints
- type Files
- func (s *Files) Delete(ctx context.Context, fileID string, workspaceID *string, ...) (*components.FileDeleteResponse, error)
- func (s *Files) Download(ctx context.Context, fileID string, workspaceID *string, ...) (io.ReadCloser, error)
- func (s *Files) List(ctx context.Context, request *operations.ListFilesRequest, ...) (*operations.ListFilesResponse, error)
- func (s *Files) Retrieve(ctx context.Context, fileID string, workspaceID *string, ...) (*components.FileResponse, error)
- func (s *Files) Upload(ctx context.Context, requestBody operations.UploadFileRequestBody, ...) (*components.FileResponse, error)
- type Generations
- func (s *Generations) GetGeneration(ctx context.Context, id string, opts ...operations.Option) (*components.GenerationResponse, error)
- func (s *Generations) ListGenerationContent(ctx context.Context, id string, opts ...operations.Option) (*components.GenerationContentResponse, error)
- func (s *Generations) SubmitFeedback(ctx context.Context, request components.SubmitGenerationFeedbackRequest, ...) (*components.SubmitGenerationFeedbackResponse, error)
- type Guardrails
- func (s *Guardrails) BulkAssignKeys(ctx context.Context, id string, ...) (*components.BulkAssignKeysResponse, error)
- func (s *Guardrails) BulkAssignMembers(ctx context.Context, id string, ...) (*components.BulkAssignMembersResponse, error)
- func (s *Guardrails) BulkUnassignKeys(ctx context.Context, id string, ...) (*components.BulkUnassignKeysResponse, error)
- func (s *Guardrails) BulkUnassignMembers(ctx context.Context, id string, ...) (*components.BulkUnassignMembersResponse, error)
- func (s *Guardrails) Create(ctx context.Context, request components.CreateGuardrailRequest, ...) (*components.CreateGuardrailResponse, error)
- func (s *Guardrails) Delete(ctx context.Context, id string, opts ...operations.Option) (*components.DeleteGuardrailResponse, error)
- func (s *Guardrails) Get(ctx context.Context, id string, opts ...operations.Option) (*components.GetGuardrailResponse, error)
- func (s *Guardrails) List(ctx context.Context, offset optionalnullable.OptionalNullable[int64], ...) (*operations.ListGuardrailsResponse, error)
- func (s *Guardrails) ListGuardrailKeyAssignments(ctx context.Context, id string, ...) (*operations.ListGuardrailKeyAssignmentsResponse, error)
- func (s *Guardrails) ListGuardrailMemberAssignments(ctx context.Context, id string, ...) (*operations.ListGuardrailMemberAssignmentsResponse, error)
- func (s *Guardrails) ListKeyAssignments(ctx context.Context, offset optionalnullable.OptionalNullable[int64], ...) (*operations.ListKeyAssignmentsResponse, error)
- func (s *Guardrails) ListMemberAssignments(ctx context.Context, offset optionalnullable.OptionalNullable[int64], ...) (*operations.ListMemberAssignmentsResponse, error)
- func (s *Guardrails) Update(ctx context.Context, id string, ...) (*components.UpdateGuardrailResponse, error)
- type HTTPClient
- type Images
- func (s *Images) Generate(ctx context.Context, request components.ImageGenerationRequest, ...) (*operations.CreateImagesResponse, error)
- func (s *Images) ListModelEndpoints(ctx context.Context, author string, slug string, opts ...operations.Option) (*components.ImageModelEndpointsResponse, error)
- func (s *Images) ListModels(ctx context.Context, opts ...operations.Option) (*components.ImageModelsListResponse, error)
- type Models
- func (s *Models) Count(ctx context.Context, outputModalities *string, opts ...operations.Option) (*components.ModelsCountResponse, error)
- func (s *Models) Get(ctx context.Context, author string, slug string, opts ...operations.Option) (*components.ModelResponse, error)
- func (s *Models) List(ctx context.Context, request *operations.GetModelsRequest, ...) (*operations.GetModelsResponse, error)
- func (s *Models) ListForUser(ctx context.Context, security operations.ListModelsUserSecurity, ...) (*operations.ListModelsUserResponse, error)
- type OAuth
- func (s *OAuth) CreateAuthCode(ctx context.Context, request operations.CreateAuthKeysCodeRequest, ...) (*operations.CreateAuthKeysCodeResponse, error)
- func (s *OAuth) CreateOauthToken(ctx context.Context, request components.TokenExchangeRequest, ...) (*components.TokenExchangeResponse, error)
- func (s *OAuth) ExchangeAuthCodeForAPIKey(ctx context.Context, request operations.ExchangeAuthCodeForAPIKeyRequest, ...) (*operations.ExchangeAuthCodeForAPIKeyResponse, error)
- func (s *OAuth) ListOauthJwks(ctx context.Context, opts ...operations.Option) (*components.OAuthJwks, error)
- type Observability
- func (s *Observability) Create(ctx context.Context, request components.CreateObservabilityDestinationRequest, ...) (*components.CreateObservabilityDestinationResponse, error)
- func (s *Observability) Delete(ctx context.Context, id string, opts ...operations.Option) (*components.DeleteObservabilityDestinationResponse, error)
- func (s *Observability) Get(ctx context.Context, id string, opts ...operations.Option) (*components.GetObservabilityDestinationResponse, error)
- func (s *Observability) List(ctx context.Context, offset optionalnullable.OptionalNullable[int64], ...) (*operations.ListObservabilityDestinationsResponse, error)
- func (s *Observability) Update(ctx context.Context, id string, ...) (*components.UpdateObservabilityDestinationResponse, error)
- type OpenRouter
- type Organization
- type Presets
- func (s *Presets) CreatePresetsChatCompletions(ctx context.Context, slug string, chatRequest components.ChatRequest, ...) (*components.CreatePresetFromInferenceResponse, error)
- func (s *Presets) CreatePresetsMessages(ctx context.Context, slug string, messagesRequest components.MessagesRequest, ...) (*components.CreatePresetFromInferenceResponse, error)
- func (s *Presets) CreatePresetsResponses(ctx context.Context, slug string, responsesRequest components.ResponsesRequest, ...) (*components.CreatePresetFromInferenceResponse, error)
- func (s *Presets) Get(ctx context.Context, slug string, opts ...operations.Option) (*components.GetPresetResponse, error)
- func (s *Presets) GetVersion(ctx context.Context, slug string, version string, opts ...operations.Option) (*components.GetPresetVersionResponse, error)
- func (s *Presets) List(ctx context.Context, offset optionalnullable.OptionalNullable[int64], ...) (*operations.ListPresetsResponse, error)
- func (s *Presets) ListVersions(ctx context.Context, slug string, ...) (*operations.ListPresetVersionsResponse, error)
- type Providers
- type Rerank
- type Responses
- type SDKOption
- func WithClient(client HTTPClient) SDKOption
- func WithHTTPReferer(httpReferer string) SDKOption
- func WithRetryConfig(retryConfig retry.Config) SDKOption
- func WithSecurity(apiKey string) SDKOption
- func WithSecuritySource(security func(context.Context) (components.Security, error)) SDKOption
- func WithServer(server string) SDKOption
- func WithServerURL(serverURL string) SDKOption
- func WithTemplatedServerURL(serverURL string, params map[string]string) SDKOption
- func WithTimeout(timeout time.Duration) SDKOption
- func WithXTitle(xTitle string) SDKOption
- type STT
- type Scim
- func (s *Scim) Create(ctx context.Context, request components.CreateScimGroupMappingRequest, ...) (*components.CreateScimGroupMappingResponse, error)
- func (s *Scim) CreateSyncJob(ctx context.Context, opts ...operations.Option) (*operations.CreateScimSyncJobResponse, error)
- func (s *Scim) Delete(ctx context.Context, id string, keepMembers operations.KeepMembers, ...) (*components.DeleteScimGroupMappingResponse, error)
- func (s *Scim) GetSyncJob(ctx context.Context, id string, opts ...operations.Option) (*components.GetScimSyncJobResponse, error)
- func (s *Scim) ListGroups(ctx context.Context, offset optionalnullable.OptionalNullable[int64], ...) (*operations.ListScimGroupsResponse, error)
- func (s *Scim) ListMappings(ctx context.Context, offset optionalnullable.OptionalNullable[int64], ...) (*operations.ListScimGroupMappingsResponse, error)
- func (s *Scim) Read(ctx context.Context, id string, opts ...operations.Option) (*components.GetScimGroupMappingResponse, error)
- func (s *Scim) Update(ctx context.Context, id string, ...) (*components.UpdateScimGroupMappingResponse, error)
- type TTS
- type VideoGeneration
- func (s *VideoGeneration) Generate(ctx context.Context, request components.VideoGenerationRequest, ...) (*components.VideoGenerationResponse, error)
- func (s *VideoGeneration) GetGeneration(ctx context.Context, jobID string, opts ...operations.Option) (*components.VideoGenerationResponse, error)
- func (s *VideoGeneration) GetVideoContent(ctx context.Context, jobID string, ...) (io.ReadCloser, error)
- func (s *VideoGeneration) ListVideosModels(ctx context.Context, opts ...operations.Option) (*components.VideoModelsListResponse, error)
- type Workspaces
- func (s *Workspaces) BulkAddMembers(ctx context.Context, id string, ...) (*components.BulkAddWorkspaceMembersResponse, error)
- func (s *Workspaces) BulkRemoveMembers(ctx context.Context, id string, ...) (*components.BulkRemoveWorkspaceMembersResponse, error)
- func (s *Workspaces) Create(ctx context.Context, request components.CreateWorkspaceRequest, ...) (*components.CreateWorkspaceResponse, error)
- func (s *Workspaces) Delete(ctx context.Context, id string, confirmDefaultWorkspaceDeletion *bool, ...) (*components.DeleteWorkspaceResponse, error)
- func (s *Workspaces) DeleteBudget(ctx context.Context, workspaceRef string, ...) (*components.DeleteWorkspaceBudgetResponse, error)
- func (s *Workspaces) Get(ctx context.Context, id string, opts ...operations.Option) (*components.GetWorkspaceResponse, error)
- func (s *Workspaces) GetBudget(ctx context.Context, workspaceRef string, ...) (*components.GetWorkspaceBudgetResponse, error)
- func (s *Workspaces) List(ctx context.Context, offset optionalnullable.OptionalNullable[int64], ...) (*operations.ListWorkspacesResponse, error)
- func (s *Workspaces) ListBudgets(ctx context.Context, workspaceRef string, opts ...operations.Option) (*components.ListWorkspaceBudgetsResponse, error)
- func (s *Workspaces) ListMembers(ctx context.Context, id string, ...) (*operations.ListWorkspaceMembersResponse, error)
- func (s *Workspaces) SetBudget(ctx context.Context, workspaceRef string, ...) (*components.UpsertWorkspaceBudgetResponse, error)
- func (s *Workspaces) Update(ctx context.Context, id string, ...) (*components.UpdateWorkspaceResponse, error)
Examples ¶
Constants ¶
const ( // Production server ServerProduction string = "production" )
Variables ¶
var ServerList = map[string]string{ ServerProduction: "https://openrouter.ai/api/v1", }
ServerList contains the list of servers available to the SDK
Functions ¶
Types ¶
type APIKeys ¶
type APIKeys struct {
// contains filtered or unexported fields
}
APIKeys - API key management endpoints
func (*APIKeys) Create ¶
func (s *APIKeys) Create(ctx context.Context, request operations.CreateKeysRequest, opts ...operations.Option) (*operations.CreateKeysResponse, error)
Create a new API key Create a new API key for the authenticated user. The plaintext `key` is returned only in this response. Treat it as a write-only, sensitive value; it cannot be retrieved later. Authenticate with a [management key](/docs/guides/overview/auth/management-api-keys). The optional `external` object associates the key with a partner-defined user and lookup key.
func (*APIKeys) Delete ¶
func (s *APIKeys) Delete(ctx context.Context, hash string, opts ...operations.Option) (*operations.DeleteKeysResponse, error)
Delete an API key Delete an existing API key. Authenticate with a [management key](/docs/guides/overview/auth/management-api-keys).
func (*APIKeys) Get ¶
func (s *APIKeys) Get(ctx context.Context, hash string, opts ...operations.Option) (*operations.GetKeyResponse, error)
Get a single API key Get a single API key by hash. [Management key](/docs/guides/overview/auth/management-api-keys) required.
func (*APIKeys) GetCurrentKeyMetadata ¶
func (s *APIKeys) GetCurrentKeyMetadata(ctx context.Context, opts ...operations.Option) (*operations.GetCurrentKeyResponse, error)
GetCurrentKeyMetadata - Get current API key Get information on the API key associated with the current authentication session
func (*APIKeys) List ¶
func (s *APIKeys) List(ctx context.Context, includeDisabled *bool, offset optionalnullable.OptionalNullable[int64], workspaceID *string, opts ...operations.Option) (*operations.ListResponse, error)
List API keys List all API keys for the authenticated user. [Management key](/docs/guides/overview/auth/management-api-keys) required.
func (*APIKeys) Update ¶
func (s *APIKeys) Update(ctx context.Context, hash string, requestBody operations.UpdateKeysRequestBody, opts ...operations.Option) (*operations.UpdateKeysResponse, error)
Update an API key Update an existing API key. Authenticate with a [management key](/docs/guides/overview/auth/management-api-keys).
type Analytics ¶
type Analytics struct {
// contains filtered or unexported fields
}
Analytics and usage endpoints
func (*Analytics) GetAnalyticsMeta ¶ added in v0.7.63
func (s *Analytics) GetAnalyticsMeta(ctx context.Context, opts ...operations.Option) (*operations.GetAnalyticsMetaResponse, error)
GetAnalyticsMeta - Get available analytics metrics and dimensions Returns the available metrics, dimensions, filter operators, and granularities for the analytics query endpoint. [Management key](/docs/guides/overview/auth/management-api-keys) required.
func (*Analytics) GetUserActivity ¶
func (s *Analytics) GetUserActivity(ctx context.Context, date *string, apiKeyHash *string, userID *string, groupBy *operations.GroupBy, workspaceID *string, opts ...operations.Option) (*components.ActivityResponse, error)
GetUserActivity - Get user activity grouped by endpoint Returns user activity data grouped by endpoint for the last 30 (completed) UTC days. Pass `workspace_id` to scope the response to a single workspace. Pass `group_by=workspace` to split each row per workspace and include `workspace_id` on every item; by default rows are aggregated across workspaces and `workspace_id` is not returned. Activity recorded before workspace resolution existed is permanently attributed to the account default workspace (no backfill is possible). [Management key](/docs/guides/overview/auth/management-api-keys) required.
func (*Analytics) QueryAnalytics ¶ added in v0.7.63
func (s *Analytics) QueryAnalytics(ctx context.Context, request operations.QueryAnalyticsRequest, opts ...operations.Option) (*operations.QueryAnalyticsResponse, error)
QueryAnalytics - Query analytics data Execute an analytics query with specified metrics, dimensions, filters, and time range. [Management key](/docs/guides/overview/auth/management-api-keys) required.
type BYOK ¶ added in v0.7.13
type BYOK struct {
// contains filtered or unexported fields
}
BYOK endpoints
func (*BYOK) Create ¶ added in v0.7.13
func (s *BYOK) Create(ctx context.Context, request components.CreateBYOKKeyRequest, opts ...operations.Option) (*components.CreateBYOKKeyResponse, error)
Create a BYOK provider credential Create a new bring-your-own-key (BYOK) provider credential. The raw key is encrypted at rest and never returned in API responses. When `workspace_id` is omitted, the credential is created in the default workspace; if that default has been deleted, the request returns a 400 and you must pass `workspace_id` explicitly. Treat the raw key as write-only; it is never returned after creation. Use `allowed_api_key_hashes` to restrict the credential to specific OpenRouter API keys. [Management key](/docs/guides/overview/auth/management-api-keys) required.
func (*BYOK) Delete ¶ added in v0.7.13
func (s *BYOK) Delete(ctx context.Context, id string, opts ...operations.Option) (*components.DeleteBYOKKeyResponse, error)
Delete a BYOK provider credential Delete (soft-delete) a bring-your-own-key (BYOK) provider credential by its `id`. The encrypted key material is wiped and the record is marked as deleted. [Management key](/docs/guides/overview/auth/management-api-keys) required.
func (*BYOK) Get ¶ added in v0.7.13
func (s *BYOK) Get(ctx context.Context, id string, opts ...operations.Option) (*components.GetBYOKKeyResponse, error)
Get a BYOK provider credential Get a single bring-your-own-key (BYOK) provider credential by its `id`. [Management key](/docs/guides/overview/auth/management-api-keys) required.
func (*BYOK) List ¶ added in v0.7.13
func (s *BYOK) List(ctx context.Context, offset optionalnullable.OptionalNullable[int64], limit *int64, workspaceID *string, provider *operations.Provider, opts ...operations.Option) (*operations.ListBYOKKeysResponse, error)
List BYOK provider credentials List the bring-your-own-key (BYOK) provider credentials for the authenticated entity's default workspace. Use the `workspace_id` query parameter to scope the result to a different workspace, or the `provider` query parameter to filter by upstream provider. [Management key](/docs/guides/overview/auth/management-api-keys) required.
func (*BYOK) Update ¶ added in v0.7.13
func (s *BYOK) Update(ctx context.Context, id string, updateBYOKKeyRequest components.UpdateBYOKKeyRequest, opts ...operations.Option) (*components.UpdateBYOKKeyResponse, error)
Update a BYOK provider credential Update an existing bring-your-own-key (BYOK) provider credential by its `id`. Include the `key` field to rotate the raw provider API key in-place (the previous key material is overwritten). Use `allowed_api_key_hashes` to restrict the credential to specific OpenRouter API keys (`null` clears the restriction). [Management key](/docs/guides/overview/auth/management-api-keys) required.
type Benchmarks ¶
type Benchmarks struct {
// contains filtered or unexported fields
}
Benchmarks endpoints
func (*Benchmarks) GetBenchmarks ¶
func (s *Benchmarks) GetBenchmarks(ctx context.Context, request *operations.GetBenchmarksRequest, opts ...operations.Option) (*components.UnifiedBenchmarksResponse, error)
GetBenchmarks - List Benchmarks Unified benchmark endpoint that aggregates scores from multiple benchmark sources (Artificial Analysis, Design Arena, and OpenRouter's own tau-bench, GPQA, and web-search evals). Filter by source to reproduce the exact shapes from the legacy per-source endpoints, or use task_type to find models suited for specific workloads. Use task_type=search (or a search_* benchmark_type) for OpenRouter's search benchmarks, which publish each model's highest-scoring eligible evaluation configuration with same-configuration runs combined by task-weighted mean. Authenticate with any valid OpenRouter API key. Rate-limited to 30 requests/minute per key and 500 requests/day per account.
type Beta ¶
type Beta struct {
// Deprecated alias of responses. Use responses instead; scheduled for removal (sunset date TBD).
Responses *BetaResponses
// contains filtered or unexported fields
}
type BetaResponses ¶ added in v0.6.0
type BetaResponses struct {
// contains filtered or unexported fields
}
BetaResponses - Deprecated alias of responses. Use responses instead; scheduled for removal (sunset date TBD).
func (*BetaResponses) Send ¶ added in v0.6.0
func (s *BetaResponses) Send(ctx context.Context, responsesRequest components.ResponsesRequest, xOpenRouterMetadata *components.MetadataLevel, opts ...operations.Option) (*operations.CreateResponsesResponse, error)
Send - Create a response Creates a streaming or non-streaming response using OpenResponses API format
type Chat ¶
type Chat struct {
// contains filtered or unexported fields
}
func (*Chat) Send ¶
func (s *Chat) Send(ctx context.Context, chatRequest components.ChatRequest, xOpenRouterMetadata *components.MetadataLevel, opts ...operations.Option) (*operations.SendChatCompletionRequestResponse, error)
Send - Create a chat completion Sends a request for a model response for the given chat conversation. Supports both streaming and non-streaming modes.
type Classifications ¶
type Classifications struct {
// contains filtered or unexported fields
}
Classifications - Task classification market-share endpoints
func (*Classifications) GetTaskClassifications ¶
func (s *Classifications) GetTaskClassifications(ctx context.Context, window *operations.Window, opts ...operations.Option) (*components.TaskClassificationResponse, error)
GetTaskClassifications - Task classification market share Returns the market-share breakdown of OpenRouter traffic by task classification (e.g. code generation, web search, summarization) over a trailing time window.
Each classification reports its share of classified sampled requests (`usage_share`) and classified sampled token volume (`token_share`) as fractions between 0 and 1. The unclassified `other` bucket is excluded. Absolute volumes are not exposed because the underlying data is sampled.
Each classification also includes a `models` array listing the top models by request volume within that classification, with their within-tag usage and token shares.
Classifications are grouped into macro-categories (Code, Data, Agent, General) with aggregate shares provided for each.
Authenticate with any valid OpenRouter API key (same key used for inference). Rate-limited to 30 requests/minute per key and 500 requests/day per account.
When republishing or quoting this data, cite as: "Source: OpenRouter (openrouter.ai/rankings), as of {as_of}."
type Containers ¶ added in v0.7.68
type Containers struct {
// contains filtered or unexported fields
}
Containers endpoints
func (*Containers) DownloadContainerFileContent ¶ added in v0.7.68
func (s *Containers) DownloadContainerFileContent(ctx context.Context, containerID string, fileID string, opts ...operations.Option) (io.ReadCloser, error)
DownloadContainerFileContent - Download container file content Streams the raw bytes of a file in a container.
func (*Containers) GetContainerFile ¶ added in v0.7.68
func (s *Containers) GetContainerFile(ctx context.Context, containerID string, fileID string, opts ...operations.Option) (*components.ContainerFile, error)
GetContainerFile - Retrieve a container file Returns the metadata of a single file in a container.
func (*Containers) ListContainerFiles ¶ added in v0.7.68
func (s *Containers) ListContainerFiles(ctx context.Context, containerID string, limit *int64, after *string, opts ...operations.Option) (*components.ContainerFileListResponse, error)
ListContainerFiles - List container files Lists the files in a container, in lexicographic path order. The container id is the canonical id returned in bash/shell tool results; a restarted session is a separate container with its own id. Paginate with `limit` and `after` (pass the previous page’s `last_id`); `has_more: true` always means the next page is fetchable that way.
func (*Containers) PromoteContainerFile ¶ added in v0.7.78
func (s *Containers) PromoteContainerFile(ctx context.Context, containerID string, fileID string, opts ...operations.Option) (*components.FileResponse, error)
PromoteContainerFile - Promote a container file into workspace documents Copies a file from the container's sandbox prefix into the workspace's durable document storage, so it outlives the container. Returns the new document in the Files API shape, with a durable file id in the documents namespace. The copy counts against the workspace's storage quota. Unlike a direct upload, promoted files are downloadable.
type Credits ¶
type Credits struct {
// contains filtered or unexported fields
}
Credits - Credit management endpoints
func (*Credits) GetCredits ¶
func (s *Credits) GetCredits(ctx context.Context, opts ...operations.Option) (*operations.GetCreditsResponse, error)
GetCredits - Get remaining credits Get total credits purchased and used for the authenticated user. [Management key](/docs/guides/overview/auth/management-api-keys) required.
type Datasets ¶
type Datasets struct {
// contains filtered or unexported fields
}
Datasets - Public OpenRouter usage datasets. Data returned by these endpoints is licensed under CC BY 4.0 (https://creativecommons.org/licenses/by/4.0/): reuse and republish it, including commercially, with attribution to OpenRouter.
func (*Datasets) GetAppRankings ¶
func (s *Datasets) GetAppRankings(ctx context.Context, request *operations.GetAppRankingsRequest, opts ...operations.Option) (*operations.GetAppRankingsResponse, error)
GetAppRankings - Top apps by token usage Returns the top public apps on OpenRouter ranked by token usage inside the requested date window, matching the public apps marketplace on openrouter.ai/apps. Token totals are `prompt_tokens + completion_tokens`; hidden and private apps are excluded and traffic from related app aliases is merged into the canonical visible app.
`sort=popular` (default) ranks by total token volume inside the window. `sort=trending` ranks by absolute excess token growth: window volume minus the average volume of the three equal-length periods immediately preceding the window. Apps with no excess growth are omitted, so `trending` may return fewer than `limit` rows.
Filter with `category` (marketplace category group, e.g. `coding`) or `subcategory` (e.g. `cli-agent`). Ranks are re-numbered 1..N after filtering. Page with `offset` — `rank` stays absolute, so the first row of `offset=50` is `rank: 51`.
Authenticate with any valid OpenRouter API key (same key used for inference). Rate-limited to 30 requests/minute per key and 500 requests/day per account.
When republishing or quoting this dataset, OpenRouter must be cited as: "Source: OpenRouter (openrouter.ai/apps), as of {as_of}."
Token counts come from each upstream provider's own tokenizer, so a token attributed to one app is not directly comparable to a token attributed to another app whose traffic flows through a different provider.
Licensed under [CC BY 4.0](https://creativecommons.org/licenses/by/4.0/): reuse and republish with attribution to OpenRouter.
func (*Datasets) GetRankingsDaily ¶
func (s *Datasets) GetRankingsDaily(ctx context.Context, request *operations.GetRankingsDailyRequest, opts ...operations.Option) (*components.RankingsDailyResponse, error)
GetRankingsDaily - Daily token totals for top 50 models Returns the top 50 public models per day by total token usage on OpenRouter, plus a single aggregated `other` row per day that sums every model outside that top 50. Token totals are `prompt_tokens + completion_tokens`, matching the public rankings chart on openrouter.ai/rankings.
Each row is a distinct `(date, model_permaslug)` pair. The `other` row uses the reserved permaslug `other` and is always returned last within its date, so callers can compute `top-50 traffic / total daily traffic` without a second request.
Optional filters slice the dataset. `period` (`day`/`week`/`month`) sets the time grain. `modality` and `context_bucket` narrow the exact dataset by output/input modality (or tool-calling activity) and request context length. `category` and `language_type` instead read a sampled, upsampled dataset whose `total_tokens` are weekly-grain estimates — they cannot be combined with each other or with the exact filters, and reject `period=day` with a 400.
Authenticate with any valid OpenRouter API key (same key used for inference). Rate-limited to 30 requests/minute per key and 500 requests/day per account.
When republishing or quoting this dataset, OpenRouter must be cited as: "Source: OpenRouter (openrouter.ai/rankings), as of {as_of}."
Token counts come from each upstream provider's own tokenizer (Anthropic counts are as reported by Anthropic, OpenAI counts are as reported by OpenAI, etc.), so a token in one row is not directly comparable to a token in another row from a different provider.
Licensed under [CC BY 4.0](https://creativecommons.org/licenses/by/4.0/): reuse and republish with attribution to OpenRouter.
func (*Datasets) GetSessionCost ¶ added in v0.7.44
func (s *Datasets) GetSessionCost(ctx context.Context, request *operations.GetSessionCostRequest, opts ...operations.Option) (*operations.GetSessionCostResponse, error)
GetSessionCost - Cost per session by harness and model Returns weekly refreshed, aggregated cost-per-session cells for the published harnesses. Sessions are never pooled across apps. Medians are of per-session USD spend, and privacy-preserving aggregation never exposes clerk_user_id values or per-session rows.
Filter by `app_slug`, `model`, or `turn_range`. Filtering by `model` alone works across apps for harness-vs-harness comparison at a fixed model. Results refresh weekly and include the source snapshot window in `meta`.
Licensed under [CC BY 4.0](https://creativecommons.org/licenses/by/4.0/): reuse and republish with attribution to OpenRouter.
type Embeddings ¶
type Embeddings struct {
// contains filtered or unexported fields
}
Embeddings - Text embedding endpoints
func (*Embeddings) Generate ¶
func (s *Embeddings) Generate(ctx context.Context, request operations.CreateEmbeddingsRequest, opts ...operations.Option) (*operations.CreateEmbeddingsResponse, error)
Generate - Submit an embedding request Submits an embedding request to the embeddings router
func (*Embeddings) ListModels ¶
func (s *Embeddings) ListModels(ctx context.Context, offset optionalnullable.OptionalNullable[int64], limit *int64, opts ...operations.Option) (*operations.ListEmbeddingsModelsResponse, error)
ListModels - List all embeddings models Returns a list of all available embeddings models and their properties
type Endpoints ¶
type Endpoints struct {
// contains filtered or unexported fields
}
Endpoints - Endpoint information
func (*Endpoints) List ¶
func (s *Endpoints) List(ctx context.Context, author string, slug string, opts ...operations.Option) (*operations.ListEndpointsResponse, error)
List all endpoints for a model
func (*Endpoints) ListZdrEndpoints ¶
func (s *Endpoints) ListZdrEndpoints(ctx context.Context, opts ...operations.Option) (*operations.ListEndpointsZdrResponse, error)
ListZdrEndpoints - Preview the impact of ZDR on the available endpoints
type Files ¶
type Files struct {
// contains filtered or unexported fields
}
Files endpoints
func (*Files) Delete ¶
func (s *Files) Delete(ctx context.Context, fileID string, workspaceID *string, provider *components.FileProvider, opts ...operations.Option) (*components.FileDeleteResponse, error)
Delete a file Deletes a file owned by the requesting workspace. Deletion is irreversible.
func (*Files) Download ¶
func (s *Files) Download(ctx context.Context, fileID string, workspaceID *string, provider *components.FileProvider, opts ...operations.Option) (io.ReadCloser, error)
Download file content Downloads the raw bytes of a file. Only files created server-side are downloadable; uploaded files return 400.
func (*Files) List ¶
func (s *Files) List(ctx context.Context, request *operations.ListFilesRequest, opts ...operations.Option) (*operations.ListFilesResponse, error)
List files Lists files belonging to the workspace of the authenticating API key.
func (*Files) Retrieve ¶
func (s *Files) Retrieve(ctx context.Context, fileID string, workspaceID *string, provider *components.FileProvider, opts ...operations.Option) (*components.FileResponse, error)
Retrieve - Get file metadata Retrieves metadata for a single file owned by the requesting workspace.
func (*Files) Upload ¶
func (s *Files) Upload(ctx context.Context, requestBody operations.UploadFileRequestBody, workspaceID *string, provider *components.FileProvider, opts ...operations.Option) (*components.FileResponse, error)
Upload a file Uploads a file to be referenced in future API calls. The file is stored under the workspace of the authenticating API key. Maximum file size: 100 MB; empty files are rejected. The file type is determined from the file contents — not the filename or the declared content type — and must be a PDF, a PNG/JPEG/GIF/WebP image, a DOCX/XLSX/PPTX document, an MP3/WAV/FLAC/OGG audio file, or UTF-8 text. Text is reported by its structure as `application/json`, `application/x-ndjson`, `text/csv`, `text/markdown`, or `text/plain`.
type Generations ¶
type Generations struct {
// contains filtered or unexported fields
}
Generations - Generation history endpoints
func (*Generations) GetGeneration ¶
func (s *Generations) GetGeneration(ctx context.Context, id string, opts ...operations.Option) (*components.GenerationResponse, error)
GetGeneration - Get request & usage metadata for a generation
func (*Generations) ListGenerationContent ¶
func (s *Generations) ListGenerationContent(ctx context.Context, id string, opts ...operations.Option) (*components.GenerationContentResponse, error)
ListGenerationContent - Get stored prompt, completion, and error content for a generation
func (*Generations) SubmitFeedback ¶ added in v0.5.13
func (s *Generations) SubmitFeedback(ctx context.Context, request components.SubmitGenerationFeedbackRequest, opts ...operations.Option) (*components.SubmitGenerationFeedbackResponse, error)
SubmitFeedback - Submit feedback for a generation Submit structured feedback on a generation the authenticated user made. [Management key](/docs/guides/overview/auth/management-api-keys) required.
type Guardrails ¶
type Guardrails struct {
// contains filtered or unexported fields
}
Guardrails endpoints
func (*Guardrails) BulkAssignKeys ¶
func (s *Guardrails) BulkAssignKeys(ctx context.Context, id string, bulkAssignKeysRequest components.BulkAssignKeysRequest, opts ...operations.Option) (*components.BulkAssignKeysResponse, error)
BulkAssignKeys - Bulk assign keys to a guardrail Assign multiple API keys to a specific guardrail. A key may hold at most one guardrail; assigning replaces any existing assignment. [Management key](/docs/guides/overview/auth/management-api-keys) required.
func (*Guardrails) BulkAssignMembers ¶
func (s *Guardrails) BulkAssignMembers(ctx context.Context, id string, bulkAssignMembersRequest components.BulkAssignMembersRequest, opts ...operations.Option) (*components.BulkAssignMembersResponse, error)
BulkAssignMembers - Bulk assign members to a guardrail Assign multiple organization members to a specific guardrail. [Management key](/docs/guides/overview/auth/management-api-keys) required.
func (*Guardrails) BulkUnassignKeys ¶
func (s *Guardrails) BulkUnassignKeys(ctx context.Context, id string, bulkUnassignKeysRequest components.BulkUnassignKeysRequest, opts ...operations.Option) (*components.BulkUnassignKeysResponse, error)
BulkUnassignKeys - Bulk unassign keys from a guardrail Unassign multiple API keys from a specific guardrail. [Management key](/docs/guides/overview/auth/management-api-keys) required.
func (*Guardrails) BulkUnassignMembers ¶
func (s *Guardrails) BulkUnassignMembers(ctx context.Context, id string, bulkUnassignMembersRequest components.BulkUnassignMembersRequest, opts ...operations.Option) (*components.BulkUnassignMembersResponse, error)
BulkUnassignMembers - Bulk unassign members from a guardrail Unassign multiple organization members from a specific guardrail. [Management key](/docs/guides/overview/auth/management-api-keys) required.
func (*Guardrails) Create ¶
func (s *Guardrails) Create(ctx context.Context, request components.CreateGuardrailRequest, opts ...operations.Option) (*components.CreateGuardrailResponse, error)
Create a guardrail Create a new guardrail for the authenticated user. A newly created guardrail enforces nothing until it is assigned to API keys or organization members; `workspace_id` places the guardrail in a workspace but does not apply it to that workspace's traffic. To restrict all traffic in a workspace, update the workspace's default guardrail instead. Set `allowed_data_regions` to enforce [In-Region Routing](/docs/guides/features/in-region-routing#enforcing-in-region-routing-with-guardrails): governed requests must arrive through one of the listed OpenRouter domains and are rejected with a 403 otherwise. [Management key](/docs/guides/overview/auth/management-api-keys) required.
func (*Guardrails) Delete ¶
func (s *Guardrails) Delete(ctx context.Context, id string, opts ...operations.Option) (*components.DeleteGuardrailResponse, error)
Delete a guardrail Delete an existing guardrail. [Management key](/docs/guides/overview/auth/management-api-keys) required.
func (*Guardrails) Get ¶
func (s *Guardrails) Get(ctx context.Context, id string, opts ...operations.Option) (*components.GetGuardrailResponse, error)
Get a guardrail Get a single guardrail by ID. [Management key](/docs/guides/overview/auth/management-api-keys) required.
func (*Guardrails) List ¶
func (s *Guardrails) List(ctx context.Context, offset optionalnullable.OptionalNullable[int64], limit *int64, workspaceID *string, opts ...operations.Option) (*operations.ListGuardrailsResponse, error)
List guardrails List all guardrails for the authenticated user. [Management key](/docs/guides/overview/auth/management-api-keys) required.
func (*Guardrails) ListGuardrailKeyAssignments ¶
func (s *Guardrails) ListGuardrailKeyAssignments(ctx context.Context, id string, offset optionalnullable.OptionalNullable[int64], limit *int64, opts ...operations.Option) (*operations.ListGuardrailKeyAssignmentsResponse, error)
ListGuardrailKeyAssignments - List key assignments for a guardrail List all API key assignments for a specific guardrail. [Management key](/docs/guides/overview/auth/management-api-keys) required.
func (*Guardrails) ListGuardrailMemberAssignments ¶
func (s *Guardrails) ListGuardrailMemberAssignments(ctx context.Context, id string, offset optionalnullable.OptionalNullable[int64], limit *int64, opts ...operations.Option) (*operations.ListGuardrailMemberAssignmentsResponse, error)
ListGuardrailMemberAssignments - List member assignments for a guardrail List all organization member assignments for a specific guardrail. [Management key](/docs/guides/overview/auth/management-api-keys) required.
func (*Guardrails) ListKeyAssignments ¶
func (s *Guardrails) ListKeyAssignments(ctx context.Context, offset optionalnullable.OptionalNullable[int64], limit *int64, opts ...operations.Option) (*operations.ListKeyAssignmentsResponse, error)
ListKeyAssignments - List all key assignments List all API key guardrail assignments for the authenticated user. [Management key](/docs/guides/overview/auth/management-api-keys) required.
func (*Guardrails) ListMemberAssignments ¶
func (s *Guardrails) ListMemberAssignments(ctx context.Context, offset optionalnullable.OptionalNullable[int64], limit *int64, opts ...operations.Option) (*operations.ListMemberAssignmentsResponse, error)
ListMemberAssignments - List all member assignments List all organization member guardrail assignments for the authenticated user. [Management key](/docs/guides/overview/auth/management-api-keys) required.
func (*Guardrails) Update ¶
func (s *Guardrails) Update(ctx context.Context, id string, updateGuardrailRequest components.UpdateGuardrailRequest, opts ...operations.Option) (*components.UpdateGuardrailResponse, error)
Update a guardrail Update an existing guardrail, or materialize an unconfigured workspace default guardrail. Collection fields use replace semantics: send the full desired set on every update. [Management key](/docs/guides/overview/auth/management-api-keys) required.
type HTTPClient ¶
HTTPClient provides an interface for supplying the SDK with a custom HTTP client
type Images ¶
type Images struct {
// contains filtered or unexported fields
}
Images endpoints
func (*Images) Generate ¶
func (s *Images) Generate(ctx context.Context, request components.ImageGenerationRequest, opts ...operations.Option) (*operations.CreateImagesResponse, error)
Generate an image Generates an image from a text prompt via the image generation router
func (*Images) ListModelEndpoints ¶
func (s *Images) ListModelEndpoints(ctx context.Context, author string, slug string, opts ...operations.Option) (*components.ImageModelEndpointsResponse, error)
ListModelEndpoints - List endpoints for an image model Returns the full per-endpoint records for an image model: each endpoint's definitive supported parameters, pricing, and passthrough allowlist.
func (*Images) ListModels ¶
func (s *Images) ListModels(ctx context.Context, opts ...operations.Option) (*components.ImageModelsListResponse, error)
ListModels - List image generation models Lists every image generation model with its top-level supported-parameter superset and a URL to its full per-endpoint records.
type Models ¶
type Models struct {
// contains filtered or unexported fields
}
Models - Model information endpoints
func (*Models) Count ¶
func (s *Models) Count(ctx context.Context, outputModalities *string, opts ...operations.Option) (*components.ModelsCountResponse, error)
Count - Get total count of available models
func (*Models) Get ¶
func (s *Models) Get(ctx context.Context, author string, slug string, opts ...operations.Option) (*components.ModelResponse, error)
Get a model by its slug Returns full details for a single model identified by its author and slug (e.g. openai/gpt-4). Supports variant suffixes (e.g. openai/gpt-4:free) and resolves known slug aliases.
func (*Models) List ¶
func (s *Models) List(ctx context.Context, request *operations.GetModelsRequest, opts ...operations.Option) (*operations.GetModelsResponse, error)
List all models and their properties
func (*Models) ListForUser ¶
func (s *Models) ListForUser(ctx context.Context, security operations.ListModelsUserSecurity, offset optionalnullable.OptionalNullable[int64], limit *int64, outputModalities *string, opts ...operations.Option) (*operations.ListModelsUserResponse, error)
ListForUser - List models filtered by user provider preferences, privacy settings, and guardrails List models filtered by user provider preferences, [privacy settings](https://openrouter.ai/docs/guides/privacy/provider-logging), and [guardrails](https://openrouter.ai/docs/guides/features/guardrails). Returns text-output models by default; pass `output_modalities` (a comma-separated list of `text`, `image`, `embeddings`, `audio`, `video`, `rerank`, `speech`, `transcription`, or `all`) to include other modalities. If requesting through a regional hostname, the results will be filtered to models that satisfy in-region routing for that region.
type OAuth ¶
type OAuth struct {
// contains filtered or unexported fields
}
OAuth authentication endpoints
func (*OAuth) CreateAuthCode ¶
func (s *OAuth) CreateAuthCode(ctx context.Context, request operations.CreateAuthKeysCodeRequest, opts ...operations.Option) (*operations.CreateAuthKeysCodeResponse, error)
CreateAuthCode - Create authorization code Create an authorization code for the PKCE flow to generate a user-controlled API key
func (*OAuth) CreateOauthToken ¶ added in v0.7.112
func (s *OAuth) CreateOauthToken(ctx context.Context, request components.TokenExchangeRequest, opts ...operations.Option) (*components.TokenExchangeResponse, error)
CreateOauthToken - Exchange a workload identity token RFC 8693 token exchange. Presents a JWT from an issuer your organization trusts (Settings → Workload identity) and receives a short-lived OpenRouter access token that acts as the API key the matching federation policy targets.
func (*OAuth) ExchangeAuthCodeForAPIKey ¶
func (s *OAuth) ExchangeAuthCodeForAPIKey(ctx context.Context, request operations.ExchangeAuthCodeForAPIKeyRequest, opts ...operations.Option) (*operations.ExchangeAuthCodeForAPIKeyResponse, error)
ExchangeAuthCodeForAPIKey - Exchange authorization code for API key Exchange an authorization code from the PKCE flow for a user-controlled API key
func (*OAuth) ListOauthJwks ¶ added in v0.7.112
func (s *OAuth) ListOauthJwks(ctx context.Context, opts ...operations.Option) (*components.OAuthJwks, error)
ListOauthJwks - OpenRouter access token signing keys RFC 7517 JWK Set containing the public keys OpenRouter signs access tokens with.
type Observability ¶
type Observability struct {
// contains filtered or unexported fields
}
Observability endpoints
func (*Observability) Create ¶
func (s *Observability) Create(ctx context.Context, request components.CreateObservabilityDestinationRequest, opts ...operations.Option) (*components.CreateObservabilityDestinationResponse, error)
Create an observability destination Create a new observability destination. A maximum of 5 destinations per type is allowed. Defaults to the authenticated entity's default workspace; use the `workspace_id` body field to scope to a different workspace. [Management key](/docs/guides/overview/auth/management-api-keys) required.
func (*Observability) Delete ¶
func (s *Observability) Delete(ctx context.Context, id string, opts ...operations.Option) (*components.DeleteObservabilityDestinationResponse, error)
Delete an observability destination Delete an existing observability destination. This performs a soft delete. [Management key](/docs/guides/overview/auth/management-api-keys) required.
func (*Observability) Get ¶
func (s *Observability) Get(ctx context.Context, id string, opts ...operations.Option) (*components.GetObservabilityDestinationResponse, error)
Get an observability destination Fetch a single observability destination by its UUID. [Management key](/docs/guides/overview/auth/management-api-keys) required.
func (*Observability) List ¶
func (s *Observability) List(ctx context.Context, offset optionalnullable.OptionalNullable[int64], limit *int64, workspaceID *string, opts ...operations.Option) (*operations.ListObservabilityDestinationsResponse, error)
List observability destinations List the observability destinations configured for the authenticated entity's default workspace. Use the `workspace_id` query parameter to scope the result to a different workspace. Only destinations with stable release status are surfaced — destinations of other types are excluded. [Management key](/docs/guides/overview/auth/management-api-keys) required.
func (*Observability) Update ¶
func (s *Observability) Update(ctx context.Context, id string, updateObservabilityDestinationRequest components.UpdateObservabilityDestinationRequest, opts ...operations.Option) (*components.UpdateObservabilityDestinationResponse, error)
Update an observability destination Update an existing observability destination. Only the fields provided in the request body are updated. [Management key](/docs/guides/overview/auth/management-api-keys) required.
type OpenRouter ¶
type OpenRouter struct {
SDKVersion string
// Analytics and usage endpoints
Analytics *Analytics
// Text-to-speech endpoints
TTS *TTS
// Speech-to-text endpoints
STT *STT
// OAuth authentication endpoints
OAuth *OAuth
// Benchmarks endpoints
Benchmarks *Benchmarks
// BYOK endpoints
BYOK *BYOK
Chat *Chat
// Task classification market-share endpoints
Classifications *Classifications
// Containers endpoints
Containers *Containers
// Credit management endpoints
Credits *Credits
// Public OpenRouter usage datasets. Data returned by these endpoints is licensed under CC BY 4.0 (https://creativecommons.org/licenses/by/4.0/): reuse and republish it, including commercially, with attribution to OpenRouter.
Datasets *Datasets
// Text embedding endpoints
Embeddings *Embeddings
// Endpoint information
Endpoints *Endpoints
// Files endpoints
Files *Files
// Generation history endpoints
Generations *Generations
// Guardrails endpoints
Guardrails *Guardrails
// Images endpoints
Images *Images
// API key management endpoints
APIKeys *APIKeys
// Model information endpoints
Models *Models
// Observability endpoints
Observability *Observability
// Organization endpoints
Organization *Organization
// Presets endpoints
Presets *Presets
// Provider information endpoints
Providers *Providers
// Rerank endpoints
Rerank *Rerank
// OpenAI-compatible Responses API endpoints
Responses *Responses
Beta *Beta
// Management endpoints for SCIM group-to-workspace mappings, authenticated with a management key. These are not the SCIM 2.0 connector endpoints for your identity provider. In your identity provider, enter the SCIM endpoint URL shown when you enable provisioning under Settings > Members > SCIM Mappings. See https://openrouter.ai/docs/guides/features/scim-mappings#set-up-provisioning.
Scim *Scim
// Video Generation endpoints
VideoGeneration *VideoGeneration
// Workspaces endpoints
Workspaces *Workspaces
// contains filtered or unexported fields
}
OpenRouter API: OpenAI-compatible API with additional OpenRouter features
https://openrouter.ai/docs - OpenRouter Documentation
func New ¶
func New(opts ...SDKOption) *OpenRouter
New creates a new instance of the SDK with the provided options
Example ¶
ExampleNew demonstrates creating a new OpenRouter client.
package main
import (
"fmt"
openrouter "github.com/OpenRouterTeam/go-sdk"
)
func main() {
sdk := openrouter.New(
openrouter.WithSecurity("your-api-key"),
)
fmt.Println(sdk.SDKVersion)
}
Output: 0.7.140
type Organization ¶
type Organization struct {
// contains filtered or unexported fields
}
Organization endpoints
func (*Organization) ListMembers ¶
func (s *Organization) ListMembers(ctx context.Context, offset optionalnullable.OptionalNullable[int64], limit *int64, opts ...operations.Option) (*operations.ListOrganizationMembersResponse, error)
ListMembers - List organization members List all members of the organization associated with the authenticated management key. [Management key](/docs/guides/overview/auth/management-api-keys) required.
type Presets ¶
type Presets struct {
// contains filtered or unexported fields
}
Presets endpoints
func (*Presets) CreatePresetsChatCompletions ¶
func (s *Presets) CreatePresetsChatCompletions(ctx context.Context, slug string, chatRequest components.ChatRequest, opts ...operations.Option) (*components.CreatePresetFromInferenceResponse, error)
CreatePresetsChatCompletions - Create a preset from a chat-completions request body Creates a preset (or a new version of an existing one) from an inference request body. Only fields that overlap with the preset config are persisted; other fields (e.g. `messages`, `stream`, `prompt`) are silently ignored.
If set, this operation will use [Security.APIKey] from the global security.
func (*Presets) CreatePresetsMessages ¶
func (s *Presets) CreatePresetsMessages(ctx context.Context, slug string, messagesRequest components.MessagesRequest, opts ...operations.Option) (*components.CreatePresetFromInferenceResponse, error)
CreatePresetsMessages - Create a preset from a messages request body Creates a preset (or a new version of an existing one) from an inference request body. Only fields that overlap with the preset config are persisted; other fields (e.g. `messages`, `stream`, `prompt`) are silently ignored.
If set, this operation will use [Security.APIKey] from the global security.
func (*Presets) CreatePresetsResponses ¶
func (s *Presets) CreatePresetsResponses(ctx context.Context, slug string, responsesRequest components.ResponsesRequest, opts ...operations.Option) (*components.CreatePresetFromInferenceResponse, error)
CreatePresetsResponses - Create a preset from a responses request body Creates a preset (or a new version of an existing one) from an inference request body. Only fields that overlap with the preset config are persisted; other fields (e.g. `messages`, `stream`, `prompt`) are silently ignored.
If set, this operation will use [Security.APIKey] from the global security.
func (*Presets) Get ¶
func (s *Presets) Get(ctx context.Context, slug string, opts ...operations.Option) (*components.GetPresetResponse, error)
Get a preset Retrieves a preset by its slug with its currently designated version inline.
If set, this operation will use [Security.APIKey] from the global security.
func (*Presets) GetVersion ¶
func (s *Presets) GetVersion(ctx context.Context, slug string, version string, opts ...operations.Option) (*components.GetPresetVersionResponse, error)
GetVersion - Get a specific version of a preset Retrieves a specific version of a preset by its slug and version number.
If set, this operation will use [Security.APIKey] from the global security.
func (*Presets) List ¶
func (s *Presets) List(ctx context.Context, offset optionalnullable.OptionalNullable[int64], limit *int64, opts ...operations.Option) (*operations.ListPresetsResponse, error)
List presets Lists all presets for the authenticated user, ordered by most recently updated first.
If set, this operation will use [Security.APIKey] from the global security.
func (*Presets) ListVersions ¶
func (s *Presets) ListVersions(ctx context.Context, slug string, offset optionalnullable.OptionalNullable[int64], limit *int64, opts ...operations.Option) (*operations.ListPresetVersionsResponse, error)
ListVersions - List versions of a preset Lists all versions of a preset, ordered by version number ascending (oldest first).
If set, this operation will use [Security.APIKey] from the global security.
type Providers ¶
type Providers struct {
// contains filtered or unexported fields
}
Providers - Provider information endpoints
func (*Providers) List ¶
func (s *Providers) List(ctx context.Context, opts ...operations.Option) (*operations.ListProvidersResponse, error)
List all providers
type Rerank ¶
type Rerank struct {
// contains filtered or unexported fields
}
Rerank endpoints
func (*Rerank) Rerank ¶
func (s *Rerank) Rerank(ctx context.Context, request operations.CreateRerankRequest, opts ...operations.Option) (*operations.CreateRerankResponse, error)
Rerank - Submit a rerank request Submits a rerank request to the rerank router
type Responses ¶
type Responses struct {
// contains filtered or unexported fields
}
OpenAI-compatible Responses API endpoints
func (*Responses) Send ¶
func (s *Responses) Send(ctx context.Context, responsesRequest components.ResponsesRequest, xOpenRouterMetadata *components.MetadataLevel, opts ...operations.Option) (*operations.CreateResponsesResponse, error)
Send - Create a response Creates a streaming or non-streaming response using OpenResponses API format
type SDKOption ¶
type SDKOption func(*OpenRouter)
func WithClient ¶
func WithClient(client HTTPClient) SDKOption
WithClient allows the overriding of the default HTTP client used by the SDK
func WithHTTPReferer ¶
WithHTTPReferer allows setting the HTTPReferer parameter for all supported operations
func WithRetryConfig ¶
func WithSecurity ¶
WithSecurity configures the SDK to use the provided security details
func WithSecuritySource ¶
WithSecuritySource configures the SDK to invoke the Security Source function on each method call to determine authentication
func WithServer ¶
WithServer allows the overriding of the default server by name
func WithServerURL ¶
WithServerURL allows providing an alternative server URL
func WithTemplatedServerURL ¶
WithTemplatedServerURL allows the overriding of the default server URL with a templated URL populated with the provided parameters
func WithTimeout ¶
WithTimeout Optional request timeout applied to each operation
func WithXTitle ¶
WithXTitle allows setting the XTitle parameter for all supported operations
type STT ¶ added in v0.7.13
type STT struct {
// contains filtered or unexported fields
}
STT - Speech-to-text endpoints
func (*STT) CreateTranscription ¶ added in v0.7.13
func (s *STT) CreateTranscription(ctx context.Context, request components.STTRequest, opts ...operations.Option) (*components.STTResponse, error)
CreateTranscription - Create transcription Transcribes audio into text. Accepts base64-encoded audio input as JSON or an OpenAI-style multipart/form-data file upload, and returns the transcribed text.
func (*STT) CreateTranscriptionMultipart ¶ added in v0.7.13
func (s *STT) CreateTranscriptionMultipart(ctx context.Context, request operations.CreateAudioTranscriptionsMultipartRequest, opts ...operations.Option) (*components.STTResponse, error)
CreateTranscriptionMultipart - Create transcription Transcribes audio into text. Accepts base64-encoded audio input as JSON or an OpenAI-style multipart/form-data file upload, and returns the transcribed text.
type Scim ¶ added in v0.7.14
type Scim struct {
// contains filtered or unexported fields
}
Scim - Management endpoints for SCIM group-to-workspace mappings, authenticated with a management key. These are not the SCIM 2.0 connector endpoints for your identity provider. In your identity provider, enter the SCIM endpoint URL shown when you enable provisioning under Settings > Members > SCIM Mappings. See https://openrouter.ai/docs/guides/features/scim-mappings#set-up-provisioning.
func (*Scim) Create ¶ added in v0.7.14
func (s *Scim) Create(ctx context.Context, request components.CreateScimGroupMappingRequest, opts ...operations.Option) (*components.CreateScimGroupMappingResponse, error)
Create a SCIM group mapping Create a SCIM group-to-workspace role mapping. Creating a mapping that already exists with the same role succeeds and re-applies the mapping to the group members. Requesting a different role for an existing mapping returns 409. [Management key](/docs/guides/overview/auth/management-api-keys) required.
func (*Scim) CreateSyncJob ¶ added in v0.7.117
func (s *Scim) CreateSyncJob(ctx context.Context, opts ...operations.Option) (*operations.CreateScimSyncJobResponse, error)
CreateSyncJob - Start a SCIM directory sync Start a SCIM directory sync. [Management key](/docs/guides/overview/auth/management-api-keys) required.
func (*Scim) Delete ¶ added in v0.7.14
func (s *Scim) Delete(ctx context.Context, id string, keepMembers operations.KeepMembers, opts ...operations.Option) (*components.DeleteScimGroupMappingResponse, error)
Delete a SCIM group mapping Delete a SCIM group-to-workspace mapping. [Management key](/docs/guides/overview/auth/management-api-keys) required.
func (*Scim) GetSyncJob ¶ added in v0.7.117
func (s *Scim) GetSyncJob(ctx context.Context, id string, opts ...operations.Option) (*components.GetScimSyncJobResponse, error)
GetSyncJob - Get SCIM directory sync status Get SCIM directory sync status. [Management key](/docs/guides/overview/auth/management-api-keys) required.
func (*Scim) ListGroups ¶ added in v0.7.14
func (s *Scim) ListGroups(ctx context.Context, offset optionalnullable.OptionalNullable[int64], limit *int64, opts ...operations.Option) (*operations.ListScimGroupsResponse, error)
ListGroups - List SCIM groups List SCIM groups for the organization. [Management key](/docs/guides/overview/auth/management-api-keys) required.
func (*Scim) ListMappings ¶ added in v0.7.14
func (s *Scim) ListMappings(ctx context.Context, offset optionalnullable.OptionalNullable[int64], limit *int64, opts ...operations.Option) (*operations.ListScimGroupMappingsResponse, error)
ListMappings - List SCIM group mappings List SCIM group-to-workspace mappings for the organization. [Management key](/docs/guides/overview/auth/management-api-keys) required.
func (*Scim) Read ¶ added in v0.7.14
func (s *Scim) Read(ctx context.Context, id string, opts ...operations.Option) (*components.GetScimGroupMappingResponse, error)
Read - Get a SCIM group mapping Get a SCIM group-to-workspace mapping. [Management key](/docs/guides/overview/auth/management-api-keys) required.
func (*Scim) Update ¶ added in v0.7.14
func (s *Scim) Update(ctx context.Context, id string, updateScimGroupMappingRequest components.UpdateScimGroupMappingRequest, opts ...operations.Option) (*components.UpdateScimGroupMappingResponse, error)
Update a SCIM group mapping Update a SCIM group mapping role. [Management key](/docs/guides/overview/auth/management-api-keys) required.
type TTS ¶ added in v0.7.13
type TTS struct {
// contains filtered or unexported fields
}
TTS - Text-to-speech endpoints
func (*TTS) CreateSpeech ¶ added in v0.7.13
func (s *TTS) CreateSpeech(ctx context.Context, request components.SpeechRequest, opts ...operations.Option) (io.ReadCloser, error)
CreateSpeech - Create speech Synthesizes audio from the input text. Returns a raw audio bytestream in the requested format (e.g. mp3, pcm, wav).
type VideoGeneration ¶
type VideoGeneration struct {
// contains filtered or unexported fields
}
VideoGeneration - Video Generation endpoints
func (*VideoGeneration) Generate ¶
func (s *VideoGeneration) Generate(ctx context.Context, request components.VideoGenerationRequest, opts ...operations.Option) (*components.VideoGenerationResponse, error)
Generate - Submit a video generation request Submits a video generation request and returns a polling URL to check status
func (*VideoGeneration) GetGeneration ¶
func (s *VideoGeneration) GetGeneration(ctx context.Context, jobID string, opts ...operations.Option) (*components.VideoGenerationResponse, error)
GetGeneration - Poll video generation status Returns job status and content URLs when completed
func (*VideoGeneration) GetVideoContent ¶
func (s *VideoGeneration) GetVideoContent(ctx context.Context, jobID string, index optionalnullable.OptionalNullable[int64], opts ...operations.Option) (io.ReadCloser, error)
GetVideoContent - Download generated video content Streams the generated video content from the upstream provider
func (*VideoGeneration) ListVideosModels ¶
func (s *VideoGeneration) ListVideosModels(ctx context.Context, opts ...operations.Option) (*components.VideoModelsListResponse, error)
ListVideosModels - List all video generation models Returns a list of all available video generation models and their properties
type Workspaces ¶
type Workspaces struct {
// contains filtered or unexported fields
}
Workspaces endpoints
func (*Workspaces) BulkAddMembers ¶
func (s *Workspaces) BulkAddMembers(ctx context.Context, id string, bulkAddWorkspaceMembersRequest components.BulkAddWorkspaceMembersRequest, opts ...operations.Option) (*components.BulkAddWorkspaceMembersResponse, error)
BulkAddMembers - Bulk add members to a workspace Add multiple organization members to a workspace. Members are assigned the same role they hold in the organization. [Management key](/docs/guides/overview/auth/management-api-keys) required.
func (*Workspaces) BulkRemoveMembers ¶
func (s *Workspaces) BulkRemoveMembers(ctx context.Context, id string, bulkRemoveWorkspaceMembersRequest components.BulkRemoveWorkspaceMembersRequest, opts ...operations.Option) (*components.BulkRemoveWorkspaceMembersResponse, error)
BulkRemoveMembers - Bulk remove members from a workspace Remove multiple members from a workspace. Members with active API keys in the workspace cannot be removed. SCIM-managed members cannot be removed; changes must be made in your identity provider. [Management key](/docs/guides/overview/auth/management-api-keys) required.
func (*Workspaces) Create ¶
func (s *Workspaces) Create(ctx context.Context, request components.CreateWorkspaceRequest, opts ...operations.Option) (*components.CreateWorkspaceResponse, error)
Create a workspace Create a new workspace for the authenticated user. [Management key](/docs/guides/overview/auth/management-api-keys) required.
func (*Workspaces) Delete ¶
func (s *Workspaces) Delete(ctx context.Context, id string, confirmDefaultWorkspaceDeletion *bool, opts ...operations.Option) (*components.DeleteWorkspaceResponse, error)
Delete a workspace Delete an existing workspace. Workspaces with active API keys cannot be deleted; remove the keys first. Deleting the default workspace requires confirm_default_workspace_deletion=true. Deleting any workspace permanently deletes its budgets and guardrails and disables its classifiers and broadcast destinations. [Management key](/docs/guides/overview/auth/management-api-keys) required.
func (*Workspaces) DeleteBudget ¶
func (s *Workspaces) DeleteBudget(ctx context.Context, workspaceRef string, interval components.WorkspaceBudgetInterval, opts ...operations.Option) (*components.DeleteWorkspaceBudgetResponse, error)
DeleteBudget - Delete a workspace budget Remove the budget for a given interval. [Management key](/docs/guides/overview/auth/management-api-keys) required.
func (*Workspaces) Get ¶
func (s *Workspaces) Get(ctx context.Context, id string, opts ...operations.Option) (*components.GetWorkspaceResponse, error)
Get a workspace Get a single workspace by ID or slug. [Management key](/docs/guides/overview/auth/management-api-keys) required.
func (*Workspaces) GetBudget ¶ added in v0.7.21
func (s *Workspaces) GetBudget(ctx context.Context, workspaceRef string, interval components.WorkspaceBudgetInterval, opts ...operations.Option) (*components.GetWorkspaceBudgetResponse, error)
GetBudget - Get a workspace budget Retrieve the budget for a given interval. [Management key](/docs/guides/overview/auth/management-api-keys) required.
func (*Workspaces) List ¶
func (s *Workspaces) List(ctx context.Context, offset optionalnullable.OptionalNullable[int64], limit *int64, opts ...operations.Option) (*operations.ListWorkspacesResponse, error)
List workspaces List all workspaces for the authenticated user. [Management key](/docs/guides/overview/auth/management-api-keys) required.
func (*Workspaces) ListBudgets ¶
func (s *Workspaces) ListBudgets(ctx context.Context, workspaceRef string, opts ...operations.Option) (*components.ListWorkspaceBudgetsResponse, error)
ListBudgets - List workspace budgets List all budgets configured for a workspace. [Management key](/docs/guides/overview/auth/management-api-keys) required.
func (*Workspaces) ListMembers ¶ added in v0.5.11
func (s *Workspaces) ListMembers(ctx context.Context, id string, offset optionalnullable.OptionalNullable[int64], limit *int64, opts ...operations.Option) (*operations.ListWorkspaceMembersResponse, error)
ListMembers - List workspace members List all members of a workspace. Returns paginated results. For the default workspace, returns all organization members (implicit membership). [Management key](/docs/guides/overview/auth/management-api-keys) required.
func (*Workspaces) SetBudget ¶
func (s *Workspaces) SetBudget(ctx context.Context, workspaceRef string, interval components.WorkspaceBudgetInterval, upsertWorkspaceBudgetRequest components.UpsertWorkspaceBudgetRequest, opts ...operations.Option) (*components.UpsertWorkspaceBudgetResponse, error)
SetBudget - Create or update a workspace budget Create or update the budget for a given interval. Budget limits must strictly decrease as the interval narrows (lifetime > monthly > weekly > daily). The optional `include_byok_in_budgets` flag is a workspace-wide setting: when provided it applies to every budget interval for the workspace, not just the interval in this request. Note that a change made here is applied to budget enforcement immediately, but an already-open workspace settings page in the web dashboard may keep showing the previous value until it is reloaded. [Management key](/docs/guides/overview/auth/management-api-keys) required.
func (*Workspaces) Update ¶
func (s *Workspaces) Update(ctx context.Context, id string, updateWorkspaceRequest components.UpdateWorkspaceRequest, opts ...operations.Option) (*components.UpdateWorkspaceResponse, error)
Update a workspace Update an existing workspace by ID or slug. [Management key](/docs/guides/overview/auth/management-api-keys) required.
Source Files
¶
- analytics.go
- apikeys.go
- benchmarks.go
- beta.go
- betaresponses.go
- byok.go
- chat.go
- classifications.go
- containers.go
- credits.go
- datasets.go
- doc.go
- embeddings.go
- endpoints.go
- files.go
- generations.go
- guardrails.go
- images.go
- models.go
- oauth.go
- observability.go
- openrouter.go
- organization.go
- presets.go
- providers.go
- rerank.go
- responses.go
- scim.go
- stt.go
- tts.go
- videogeneration.go
- workspaces.go
