Observability - Go SDK
Observability - Go SDK
The Go SDK and docs are currently in beta. Report issues on GitHub.
Overview
Observability endpoints
Available Operations
- List - List observability destinations
- Create - Create an observability destination
- Delete - Delete an observability destination
- Get - Get an observability destination
- Update - Update an observability destination
List
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 required.
Example Usage
1 package main 2 3 import( 4 "context" 5 "os" 6 openrouter "github.com/OpenRouterTeam/go-sdk" 7 "github.com/OpenRouterTeam/go-sdk/optionalnullable" 8 "log" 9 ) 10 11 func main() { 12 ctx := context.Background() 13 14 s := openrouter.New( 15 openrouter.WithSecurity(os.Getenv("OPENROUTER_API_KEY")), 16 ) 17 18 res, err := s.Observability.List(ctx, optionalnullable.From[int64](nil), nil, nil) 19 if err != nil { 20 log.Fatal(err) 21 } 22 if res != nil { 23 for { 24 // handle items 25 26 res, err = res.Next() 27 28 if err != nil { 29 // handle error 30 } 31 32 if res == nil { 33 break 34 } 35 } 36 } 37 }
Parameters
| Parameter | Type | Required | Description | Example |
|---|---|---|---|---|
ctx | context.Context | ✔️ | The context to use for the request. | |
offset | optionalnullable.OptionalNullable[int64] | ➖ | Number of records to skip for pagination | 0 |
limit | *int64 | ➖ | Maximum number of records to return (max 100) | 50 |
workspaceID | *string | ➖ | Optional workspace ID to filter by. Defaults to the authenticated entity’s default workspace. | 550e8400-e29b-41d4-a716-446655440000 |
opts | []operations.Option | ➖ | The options for this request. |
Response
*operations.ListObservabilityDestinationsResponse, error
Errors
| Error Type | Status Code | Content Type |
|---|---|---|
| sdkerrors.UnauthorizedResponseError | 401 | application/json |
| sdkerrors.InternalServerResponseError | 500 | application/json |
| sdkerrors.APIError | 4XX, 5XX | */* |
Create
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 required.
Example Usage
1 package main 2 3 import( 4 "context" 5 "os" 6 openrouter "github.com/OpenRouterTeam/go-sdk" 7 "github.com/OpenRouterTeam/go-sdk/models/components" 8 "log" 9 ) 10 11 func main() { 12 ctx := context.Background() 13 14 s := openrouter.New( 15 openrouter.WithSecurity(os.Getenv("OPENROUTER_API_KEY")), 16 ) 17 18 res, err := s.Observability.Create(ctx, components.CreateObservabilityDestinationRequest{ 19 Config: map[string]any{ 20 "baseUrl": "https://us.cloud.langfuse.com", 21 "publicKey": "pk-l...EfGh", 22 "secretKey": "sk-l...AbCd", 23 }, 24 Name: "Production Langfuse", 25 Type: components.CreateObservabilityDestinationRequestTypeLangfuse, 26 }) 27 if err != nil { 28 log.Fatal(err) 29 } 30 if res != nil { 31 switch res.Data.Type { 32 case components.ObservabilityDestinationTypeArize: 33 // res.Data.ObservabilityArizeDestination is populated 34 case components.ObservabilityDestinationTypeBraintrust: 35 // res.Data.ObservabilityBraintrustDestination is populated 36 case components.ObservabilityDestinationTypeClickhouse: 37 // res.Data.ObservabilityClickhouseDestination is populated 38 case components.ObservabilityDestinationTypeDatadog: 39 // res.Data.ObservabilityDatadogDestination is populated 40 case components.ObservabilityDestinationTypeGrafana: 41 // res.Data.ObservabilityGrafanaDestination is populated 42 case components.ObservabilityDestinationTypeLangfuse: 43 // res.Data.ObservabilityLangfuseDestination is populated 44 case components.ObservabilityDestinationTypeLangsmith: 45 // res.Data.ObservabilityLangsmithDestination is populated 46 case components.ObservabilityDestinationTypeNewrelic: 47 // res.Data.ObservabilityNewrelicDestination is populated 48 case components.ObservabilityDestinationTypeOpik: 49 // res.Data.ObservabilityOpikDestination is populated 50 case components.ObservabilityDestinationTypeOtelCollector: 51 // res.Data.ObservabilityOtelCollectorDestination is populated 52 case components.ObservabilityDestinationTypePosthog: 53 // res.Data.ObservabilityPosthogDestination is populated 54 case components.ObservabilityDestinationTypeRamp: 55 // res.Data.ObservabilityRampDestination is populated 56 case components.ObservabilityDestinationTypeS3: 57 // res.Data.ObservabilityS3Destination is populated 58 case components.ObservabilityDestinationTypeSentry: 59 // res.Data.ObservabilitySentryDestination is populated 60 case components.ObservabilityDestinationTypeSnowflake: 61 // res.Data.ObservabilitySnowflakeDestination is populated 62 case components.ObservabilityDestinationTypeWeave: 63 // res.Data.ObservabilityWeaveDestination is populated 64 case components.ObservabilityDestinationTypeWebhook: 65 // res.Data.ObservabilityWebhookDestination is populated 66 default: 67 // Unknown type - use res.Data.GetUnknownRaw() for raw JSON 68 } 69 70 } 71 }
Parameters
| Parameter | Type | Required | Description |
|---|---|---|---|
ctx | context.Context | ✔️ | The context to use for the request. |
request | components.CreateObservabilityDestinationRequest | ✔️ | The request object to use for the request. |
opts | []operations.Option | ➖ | The options for this request. |
Response
*components.CreateObservabilityDestinationResponse, error
Errors
| Error Type | Status Code | Content Type |
|---|---|---|
| sdkerrors.BadRequestResponseError | 400 | application/json |
| sdkerrors.UnauthorizedResponseError | 401 | application/json |
| sdkerrors.ForbiddenResponseError | 403 | application/json |
| sdkerrors.ConflictResponseError | 409 | application/json |
| sdkerrors.InternalServerResponseError | 500 | application/json |
| sdkerrors.APIError | 4XX, 5XX | */* |
Delete
Delete an existing observability destination. This performs a soft delete. Management key required.
Example Usage
1 package main 2 3 import( 4 "context" 5 "os" 6 openrouter "github.com/OpenRouterTeam/go-sdk" 7 "log" 8 ) 9 10 func main() { 11 ctx := context.Background() 12 13 s := openrouter.New( 14 openrouter.WithSecurity(os.Getenv("OPENROUTER_API_KEY")), 15 ) 16 17 res, err := s.Observability.Delete(ctx, "99999999-aaaa-bbbb-cccc-dddddddddddd") 18 if err != nil { 19 log.Fatal(err) 20 } 21 if res != nil { 22 // handle response 23 } 24 }
Parameters
| Parameter | Type | Required | Description | Example |
|---|---|---|---|---|
ctx | context.Context | ✔️ | The context to use for the request. | |
id | string | ✔️ | The destination ID (UUID). | 99999999-aaaa-bbbb-cccc-dddddddddddd |
opts | []operations.Option | ➖ | The options for this request. |
Response
*components.DeleteObservabilityDestinationResponse, error
Errors
| Error Type | Status Code | Content Type |
|---|---|---|
| sdkerrors.UnauthorizedResponseError | 401 | application/json |
| sdkerrors.NotFoundResponseError | 404 | application/json |
| sdkerrors.InternalServerResponseError | 500 | application/json |
| sdkerrors.APIError | 4XX, 5XX | */* |
Get
Fetch a single observability destination by its UUID. Management key required.
Example Usage
1 package main 2 3 import( 4 "context" 5 "os" 6 openrouter "github.com/OpenRouterTeam/go-sdk" 7 "log" 8 "github.com/OpenRouterTeam/go-sdk/models/components" 9 ) 10 11 func main() { 12 ctx := context.Background() 13 14 s := openrouter.New( 15 openrouter.WithSecurity(os.Getenv("OPENROUTER_API_KEY")), 16 ) 17 18 res, err := s.Observability.Get(ctx, "99999999-aaaa-bbbb-cccc-dddddddddddd") 19 if err != nil { 20 log.Fatal(err) 21 } 22 if res != nil { 23 switch res.Data.Type { 24 case components.ObservabilityDestinationTypeArize: 25 // res.Data.ObservabilityArizeDestination is populated 26 case components.ObservabilityDestinationTypeBraintrust: 27 // res.Data.ObservabilityBraintrustDestination is populated 28 case components.ObservabilityDestinationTypeClickhouse: 29 // res.Data.ObservabilityClickhouseDestination is populated 30 case components.ObservabilityDestinationTypeDatadog: 31 // res.Data.ObservabilityDatadogDestination is populated 32 case components.ObservabilityDestinationTypeGrafana: 33 // res.Data.ObservabilityGrafanaDestination is populated 34 case components.ObservabilityDestinationTypeLangfuse: 35 // res.Data.ObservabilityLangfuseDestination is populated 36 case components.ObservabilityDestinationTypeLangsmith: 37 // res.Data.ObservabilityLangsmithDestination is populated 38 case components.ObservabilityDestinationTypeNewrelic: 39 // res.Data.ObservabilityNewrelicDestination is populated 40 case components.ObservabilityDestinationTypeOpik: 41 // res.Data.ObservabilityOpikDestination is populated 42 case components.ObservabilityDestinationTypeOtelCollector: 43 // res.Data.ObservabilityOtelCollectorDestination is populated 44 case components.ObservabilityDestinationTypePosthog: 45 // res.Data.ObservabilityPosthogDestination is populated 46 case components.ObservabilityDestinationTypeRamp: 47 // res.Data.ObservabilityRampDestination is populated 48 case components.ObservabilityDestinationTypeS3: 49 // res.Data.ObservabilityS3Destination is populated 50 case components.ObservabilityDestinationTypeSentry: 51 // res.Data.ObservabilitySentryDestination is populated 52 case components.ObservabilityDestinationTypeSnowflake: 53 // res.Data.ObservabilitySnowflakeDestination is populated 54 case components.ObservabilityDestinationTypeWeave: 55 // res.Data.ObservabilityWeaveDestination is populated 56 case components.ObservabilityDestinationTypeWebhook: 57 // res.Data.ObservabilityWebhookDestination is populated 58 default: 59 // Unknown type - use res.Data.GetUnknownRaw() for raw JSON 60 } 61 62 } 63 }
Parameters
| Parameter | Type | Required | Description | Example |
|---|---|---|---|---|
ctx | context.Context | ✔️ | The context to use for the request. | |
id | string | ✔️ | The destination ID (UUID). | 99999999-aaaa-bbbb-cccc-dddddddddddd |
opts | []operations.Option | ➖ | The options for this request. |
Response
*components.GetObservabilityDestinationResponse, error
Errors
| Error Type | Status Code | Content Type |
|---|---|---|
| sdkerrors.UnauthorizedResponseError | 401 | application/json |
| sdkerrors.NotFoundResponseError | 404 | application/json |
| sdkerrors.InternalServerResponseError | 500 | application/json |
| sdkerrors.APIError | 4XX, 5XX | */* |
Update
Update an existing observability destination. Only the fields provided in the request body are updated. Management key required.
Example Usage
1 package main 2 3 import( 4 "context" 5 "os" 6 openrouter "github.com/OpenRouterTeam/go-sdk" 7 "github.com/OpenRouterTeam/go-sdk/models/components" 8 "log" 9 ) 10 11 func main() { 12 ctx := context.Background() 13 14 s := openrouter.New( 15 openrouter.WithSecurity(os.Getenv("OPENROUTER_API_KEY")), 16 ) 17 18 res, err := s.Observability.Update(ctx, "99999999-aaaa-bbbb-cccc-dddddddddddd", components.UpdateObservabilityDestinationRequest{ 19 Enabled: openrouter.Pointer(false), 20 Name: openrouter.Pointer("Updated Langfuse"), 21 }) 22 if err != nil { 23 log.Fatal(err) 24 } 25 if res != nil { 26 switch res.Data.Type { 27 case components.ObservabilityDestinationTypeArize: 28 // res.Data.ObservabilityArizeDestination is populated 29 case components.ObservabilityDestinationTypeBraintrust: 30 // res.Data.ObservabilityBraintrustDestination is populated 31 case components.ObservabilityDestinationTypeClickhouse: 32 // res.Data.ObservabilityClickhouseDestination is populated 33 case components.ObservabilityDestinationTypeDatadog: 34 // res.Data.ObservabilityDatadogDestination is populated 35 case components.ObservabilityDestinationTypeGrafana: 36 // res.Data.ObservabilityGrafanaDestination is populated 37 case components.ObservabilityDestinationTypeLangfuse: 38 // res.Data.ObservabilityLangfuseDestination is populated 39 case components.ObservabilityDestinationTypeLangsmith: 40 // res.Data.ObservabilityLangsmithDestination is populated 41 case components.ObservabilityDestinationTypeNewrelic: 42 // res.Data.ObservabilityNewrelicDestination is populated 43 case components.ObservabilityDestinationTypeOpik: 44 // res.Data.ObservabilityOpikDestination is populated 45 case components.ObservabilityDestinationTypeOtelCollector: 46 // res.Data.ObservabilityOtelCollectorDestination is populated 47 case components.ObservabilityDestinationTypePosthog: 48 // res.Data.ObservabilityPosthogDestination is populated 49 case components.ObservabilityDestinationTypeRamp: 50 // res.Data.ObservabilityRampDestination is populated 51 case components.ObservabilityDestinationTypeS3: 52 // res.Data.ObservabilityS3Destination is populated 53 case components.ObservabilityDestinationTypeSentry: 54 // res.Data.ObservabilitySentryDestination is populated 55 case components.ObservabilityDestinationTypeSnowflake: 56 // res.Data.ObservabilitySnowflakeDestination is populated 57 case components.ObservabilityDestinationTypeWeave: 58 // res.Data.ObservabilityWeaveDestination is populated 59 case components.ObservabilityDestinationTypeWebhook: 60 // res.Data.ObservabilityWebhookDestination is populated 61 default: 62 // Unknown type - use res.Data.GetUnknownRaw() for raw JSON 63 } 64 65 } 66 }
Parameters
| Parameter | Type | Required | Description | Example |
|---|---|---|---|---|
ctx | context.Context | ✔️ | The context to use for the request. | |
id | string | ✔️ | The destination ID (UUID). | 99999999-aaaa-bbbb-cccc-dddddddddddd |
updateObservabilityDestinationRequest | components.UpdateObservabilityDestinationRequest | ✔️ | N/A | {"enabled": false,"name": "Updated Langfuse"} |
opts | []operations.Option | ➖ | The options for this request. |
Response
*components.UpdateObservabilityDestinationResponse, error
Errors
| Error Type | Status Code | Content Type |
|---|---|---|
| sdkerrors.BadRequestResponseError | 400 | application/json |
| sdkerrors.UnauthorizedResponseError | 401 | application/json |
| sdkerrors.NotFoundResponseError | 404 | application/json |
| sdkerrors.ConflictResponseError | 409 | application/json |
| sdkerrors.InternalServerResponseError | 500 | application/json |
| sdkerrors.APIError | 4XX, 5XX | */* |