Endpoints - Go SDK

Endpoints method reference

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

Overview

Endpoint information

Available Operations

  • List - List all endpoints for a model
  • ListZdrEndpoints - Preview the impact of ZDR on the available endpoints

List

List all endpoints for a model

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.Endpoints.List(ctx, "<value>", "<value>")
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.
authorstring✔️The author/organization of the modelopenai
slugstring✔️The model sluggpt-4
opts[]operations.OptionThe options for this request.

Response

*operations.ListEndpointsResponse, error

Errors

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

ListZdrEndpoints

Preview the impact of ZDR on the available endpoints

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.Endpoints.ListZdrEndpoints(ctx)
18 if err != nil {
19 log.Fatal(err)
20 }
21 if res != nil {
22 // handle response
23 }
24}

Parameters

ParameterTypeRequiredDescription
ctxcontext.Context✔️The context to use for the request.
opts[]operations.OptionThe options for this request.

Response

*operations.ListEndpointsZdrResponse, error

Errors

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