Skip to main content
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

package main

import(
	"context"
	"os"
	openrouter "github.com/OpenRouterTeam/go-sdk"
	"log"
)

func main() {
    ctx := context.Background()

    s := openrouter.New(
        openrouter.WithSecurity(os.Getenv("OPENROUTER_API_KEY")),
    )

    res, err := s.Models.List(ctx, nil, nil, nil)
    if err != nil {
        log.Fatal(err)
    }
    if res != nil {
        // handle response
    }
}

Parameters

ParameterTypeRequiredDescriptionExample
ctxcontext.Context:heavy_check_mark:The context to use for the request.
category*operations.Category:heavy_minus_sign:Filter models by use case categoryprogramming
supportedParameters*string:heavy_minus_sign:Filter models by supported parameter (comma-separated)temperature
outputModalities*string:heavy_minus_sign: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:heavy_minus_sign: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

package main

import(
	"context"
	"os"
	openrouter "github.com/OpenRouterTeam/go-sdk"
	"log"
)

func main() {
    ctx := context.Background()

    s := openrouter.New(
        openrouter.WithSecurity(os.Getenv("OPENROUTER_API_KEY")),
    )

    res, err := s.Models.Count(ctx, nil)
    if err != nil {
        log.Fatal(err)
    }
    if res != nil {
        // handle response
    }
}

Parameters

ParameterTypeRequiredDescriptionExample
ctxcontext.Context:heavy_check_mark:The context to use for the request.
outputModalities*string:heavy_minus_sign: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:heavy_minus_sign: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

package main

import(
	"context"
	openrouter "github.com/OpenRouterTeam/go-sdk"
	"os"
	"github.com/OpenRouterTeam/go-sdk/models/operations"
	"log"
)

func main() {
    ctx := context.Background()

    s := openrouter.New()

    res, err := s.Models.ListForUser(ctx, operations.ListModelsUserSecurity{
        Bearer: os.Getenv("OPENROUTER_BEARER"),
    })
    if err != nil {
        log.Fatal(err)
    }
    if res != nil {
        // handle response
    }
}

Parameters

ParameterTypeRequiredDescription
ctxcontext.Context:heavy_check_mark:The context to use for the request.
securityoperations.ListModelsUserSecurity:heavy_check_mark:The security requirements to use for the request.
opts[]operations.Option:heavy_minus_sign: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*/*