For AI agents: a documentation index is available at the root level at /llms.txt and /llms-full.txt. Append /llms.txt to any URL for a page-level index, or .md for the markdown version of any page.
ModelsChatRankingsDocs
DocsAPI ReferenceClient SDKsAgent SDKCookbookChangelog
DocsAPI ReferenceClient SDKsAgent SDKCookbookChangelog
    • Overview
    • Usage for Agents
  • TypeScript SDK
    • Overview
  • Python SDK
    • Overview
  • Go SDK
      • Analytics
      • APIKeys
      • Byok
      • Chat
      • Credits
      • Embeddings
      • Endpoints
      • Generations
      • Guardrails
        • Models
      • OAuth
      • Observability
      • Organization
      • Presets
      • Providers
      • Rerank
      • Beta.Responses
      • Transcriptions
      • Speech
      • VideoGeneration
      • Workspaces
  • DevTools
    • Overview
    • Migrating to @openrouter/agent
LogoLogo
ModelsChatRankingsDocs
On this page
  • Overview
  • Available Operations
  • List
  • Example Usage
  • Parameters
  • Response
  • Errors
  • Count
  • Example Usage
  • Parameters
  • Response
  • Errors
  • ListForUser
  • Example Usage
  • Parameters
  • Response
  • Errors
Go SDKAPI ReferenceModels

Models - Go SDK

Models method reference
Was this page helpful?
Previous

OAuth - Go SDK

OAuth method reference
Next
Built with

The Go SDK and docs are currently in beta. Report issues on GitHub.

Overview

Model information endpoints

Available Operations

  • List - List all models and their properties
  • Count - Get total count of available models
  • ListForUser - List models filtered by user provider preferences, privacy settings, and guardrails

List

List all models and their properties

Example Usage

1package main
2
3import(
4 "context"
5 "os"
6 openrouter "github.com/OpenRouterTeam/go-sdk"
7 "log"
8)
9
10func main() {
11 ctx := context.Background()
12
13 s := openrouter.New(
14 openrouter.WithSecurity(os.Getenv("OPENROUTER_API_KEY")),
15 )
16
17 res, err := s.Models.List(ctx, nil, nil, nil)
18 if err != nil {
19 log.Fatal(err)
20 }
21 if res != nil {
22 // handle response
23 }
24}

Parameters

ParameterTypeRequiredDescriptionExample
ctxcontext.Context✔️The context to use for the request.
category*operations.Category➖Filter models by use case categoryprogramming
supportedParameters*string➖Filter models by supported parameter (comma-separated)temperature
outputModalities*string➖Filter models by output modality. Accepts a comma-separated list of modalities (text, image, audio, embeddings) or “all” to include all models. Defaults to “text”.text
opts[]operations.Option➖The options for this request.

Response

*components.ModelsListResponse, error

Errors

Error TypeStatus CodeContent Type
sdkerrors.BadRequestResponseError400application/json
sdkerrors.InternalServerResponseError500application/json
sdkerrors.APIError4XX, 5XX*/*

Count

Get total count of available models

Example Usage

1package main
2
3import(
4 "context"
5 "os"
6 openrouter "github.com/OpenRouterTeam/go-sdk"
7 "log"
8)
9
10func main() {
11 ctx := context.Background()
12
13 s := openrouter.New(
14 openrouter.WithSecurity(os.Getenv("OPENROUTER_API_KEY")),
15 )
16
17 res, err := s.Models.Count(ctx, nil)
18 if err != nil {
19 log.Fatal(err)
20 }
21 if res != nil {
22 // handle response
23 }
24}

Parameters

ParameterTypeRequiredDescriptionExample
ctxcontext.Context✔️The context to use for the request.
outputModalities*string➖Filter models by output modality. Accepts a comma-separated list of modalities (text, image, audio, embeddings) or “all” to include all models. Defaults to “text”.text
opts[]operations.Option➖The options for this request.

Response

*components.ModelsCountResponse, error

Errors

Error TypeStatus CodeContent Type
sdkerrors.BadRequestResponseError400application/json
sdkerrors.InternalServerResponseError500application/json
sdkerrors.APIError4XX, 5XX*/*

ListForUser

List models filtered by user provider preferences, privacy settings, and guardrails. If requesting through eu.openrouter.ai/api/v1/... the results will be filtered to models that satisfy EU in-region routing.

Example Usage

1package main
2
3import(
4 "context"
5 openrouter "github.com/OpenRouterTeam/go-sdk"
6 "os"
7 "github.com/OpenRouterTeam/go-sdk/models/operations"
8 "log"
9)
10
11func main() {
12 ctx := context.Background()
13
14 s := openrouter.New()
15
16 res, err := s.Models.ListForUser(ctx, operations.ListModelsUserSecurity{
17 Bearer: os.Getenv("OPENROUTER_BEARER"),
18 })
19 if err != nil {
20 log.Fatal(err)
21 }
22 if res != nil {
23 // handle response
24 }
25}

Parameters

ParameterTypeRequiredDescription
ctxcontext.Context✔️The context to use for the request.
securityoperations.ListModelsUserSecurity✔️The security requirements to use for the request.
opts[]operations.Option➖The options for this request.

Response

*components.ModelsListResponse, error

Errors

Error TypeStatus CodeContent Type
sdkerrors.UnauthorizedResponseError401application/json
sdkerrors.NotFoundResponseError404application/json
sdkerrors.InternalServerResponseError500application/json
sdkerrors.APIError4XX, 5XX*/*