Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
33 changes: 15 additions & 18 deletions .speakeasy/gen.lock
Original file line number Diff line number Diff line change
@@ -1,18 +1,18 @@
lockVersion: 2.0.0
id: 9eea3e30-2722-4060-973b-57b7f1f75dc0
management:
docChecksum: ac3a7b04eaceb931e69063c8dcd71975
docChecksum: a93462ad95eb961164f13303e6e306c6
docVersion: 1.0.0
speakeasyVersion: 1.787.0
generationVersion: 2.914.0
releaseVersion: 0.9.73
configChecksum: 3c0ecea634c105ba07e577b84be5332c
releaseVersion: 0.9.74
configChecksum: 9ebde78a96f3570169ff9e14545b3061
repoURL: https://github.com/OpenRouterTeam/go-sdk.git
installationURL: https://github.com/OpenRouterTeam/go-sdk
persistentEdits:
generation_id: 0a960cc1-56cf-4f78-9c09-1e9d27f5fda2
pristine_commit_hash: d439f367a3a5b2773fa4eebf1f80c2092b737b5f
pristine_tree_hash: 396a283133a91445b8cc661c17ff5e9d8a15f570
generation_id: 2660e758-e0dc-4f93-a997-295b7c6bbbe2
pristine_commit_hash: 1cd01256422af856d41358b72c2774edc7a4e861
pristine_tree_hash: 638c69310ae5dc307867cc2f64ae5bfd85bace00
features:
go:
acceptHeaders: 2.81.2
Expand Down Expand Up @@ -9613,8 +9613,8 @@ trackedFiles:
pristine_git_object: 4450621b2b37244f5112c6892a4bcb3444f870cb
docs/sdks/generations/README.mdx:
id: a754fecc8514
last_write_checksum: sha1:a9e20fd48f256f14f3e6e0a8d70a438d36fbaf5c
pristine_git_object: 9a2e107940f5cf95d9bc303b34db3eadc5299df5
last_write_checksum: sha1:6441d3933a67b128d2f9a9eaf142734fbe7b36e0
pristine_git_object: ce8b298011d2a75efa1ec34e78309aaed8ccf592
docs/sdks/guardrails/README.mdx:
id: a0cd4218b8fa
last_write_checksum: sha1:6f75510b9c36c77e90a32d0d517b492e68a72458
Expand Down Expand Up @@ -9717,8 +9717,8 @@ trackedFiles:
pristine_git_object: 0c805449044890b2963573442c4f3617a9a0bb4f
generations.go:
id: ad539e13a3f6
last_write_checksum: sha1:405d810391b9a48b32223660be530f209a73d5d2
pristine_git_object: 81a1bf802ed333019dc9be1abb890593509a1f38
last_write_checksum: sha1:6b40a654009d58094d7feeb34cb7e1ac94c3e608
pristine_git_object: b7bdaa3c9dae9373949d3207a59adf262e241090
go.mod:
id: c47645c391ad
last_write_checksum: sha1:ba90465104f4b129a0ced01d50d453c828d3cc41
Expand Down Expand Up @@ -13937,8 +13937,8 @@ trackedFiles:
pristine_git_object: 46df65b755cfb5609b7c6763fcbb8e7d3cbd44b4
openrouter.go:
id: 207ad004b774
last_write_checksum: sha1:c0164dcdf9ffb9d45700cc52d29d643d7f2943ed
pristine_git_object: 3888c53868bd6c424b897dbd44bbe08d57a545d1
last_write_checksum: sha1:5ec60bbd95c0f0613d9f0d522a9033d10ea2472d
pristine_git_object: 9309fb9c086bb133311caa7d424052207c6bcb4b
optionalnullable/optionalnullable.go:
id: ce60f259ead3
last_write_checksum: sha1:d6aff1a420c31e025ea21d46cf056e305ae76fe8
Expand Down Expand Up @@ -14195,6 +14195,8 @@ examples:
application/json: {"error": {"code": 529, "message": "Provider returned error"}}
"400":
application/json: {"error": {"code": 400, "message": "Invalid request parameters"}}
"403":
application/json: {"error": {"code": 403, "message": "Only management keys can perform this operation"}}
listModelsCount:
speakeasy-default-list-models-count:
responses:
Expand Down Expand Up @@ -18366,9 +18368,4 @@ examples:
examplesVersion: 1.0.2
releaseNotes: |
## Go SDK Changes:
* `OpenRouter.ExternalUsers.List()`: `error.status[403]` **Added**
* `OpenRouter.ExternalUsers.Get()`: `error.status[403]` **Added**
* `OpenRouter.Presets.List()`: `error.status[403]` **Added**
* `OpenRouter.Presets.Get()`: `error.status[403]` **Added**
* `OpenRouter.Presets.ListVersions()`: `error.status[403]` **Added**
* `OpenRouter.Presets.GetVersion()`: `error.status[403]` **Added**
* `OpenRouter.Generations.GetGeneration()`: `error.status[403]` **Added**
2 changes: 1 addition & 1 deletion .speakeasy/gen.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ generation:
documentation: mintlify
preApplyUnionDiscriminators: true
go:
version: 0.9.73
version: 0.9.74
additionalDependencies: {}
baseErrorName: OpenRouterError
clientServerStatusCodesAsErrors: true
Expand Down
10 changes: 10 additions & 0 deletions .speakeasy/out.openapi.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -40728,6 +40728,16 @@ paths:
schema:
$ref: '#/components/schemas/PaymentRequiredResponse'
description: 'Payment Required - Insufficient credits or quota to complete request'
'403':
content:
application/json:
example:
error:
code: 403
message: 'Management key does not have permission for this request'
schema:
$ref: '#/components/schemas/ForbiddenResponse'
description: 'Forbidden - The management key does not have permission for this request'
'404':
content:
application/json:
Expand Down
10 changes: 5 additions & 5 deletions .speakeasy/workflow.lock
Original file line number Diff line number Diff line change
Expand Up @@ -2,19 +2,19 @@ speakeasyVersion: 1.787.0
sources:
OpenRouter API:
sourceNamespace: open-router-chat-completions-api
sourceRevisionDigest: sha256:6c675e0899fba95c15cb5175df17607d0c33e4501d004107d5021af7f831c3a2
sourceBlobDigest: sha256:ba3ff8f63383f0fdef9b1f9c3f3fd1ed0a8a59bbe85b58c3b493426351f93d28
sourceRevisionDigest: sha256:979377bc2fc9dd14b59a56a29fd03c70e667facc0a54a44e38eb216e6c70bb12
sourceBlobDigest: sha256:8dcda949dff806c81167813248db1fd3b237c36df97bed8e8d3faa1b68ca1323
tags:
- latest
- 1.0.0
targets:
openrouter:
source: OpenRouter API
sourceNamespace: open-router-chat-completions-api
sourceRevisionDigest: sha256:6c675e0899fba95c15cb5175df17607d0c33e4501d004107d5021af7f831c3a2
sourceBlobDigest: sha256:ba3ff8f63383f0fdef9b1f9c3f3fd1ed0a8a59bbe85b58c3b493426351f93d28
sourceRevisionDigest: sha256:979377bc2fc9dd14b59a56a29fd03c70e667facc0a54a44e38eb216e6c70bb12
sourceBlobDigest: sha256:8dcda949dff806c81167813248db1fd3b237c36df97bed8e8d3faa1b68ca1323
codeSamplesNamespace: open-router-chat-completions-api-go-code-samples
codeSamplesRevisionDigest: sha256:34ba4fb6f4b60a8733dfec5a0b353b797f4d329a8a5d48920c2d4dee25c94281
codeSamplesRevisionDigest: sha256:d6372ccb1d583f2f3ff7adfc86010e065dd807e001b0c91a98adcccf54a1b149
workflow:
workflowVersion: 1.0.0
speakeasyVersion: 1.787.0
Expand Down
2 changes: 1 addition & 1 deletion OVERVIEW.md
Original file line number Diff line number Diff line change
Expand Up @@ -117,7 +117,7 @@ go get github.com/OpenRouterTeam/go-sdk
For beta releases, pin an explicit version:

```bash
go get github.com/OpenRouterTeam/go-sdk@v0.9.73
go get github.com/OpenRouterTeam/go-sdk@v0.9.74
```

**Requirements:** Go 1.25 or higher
Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ To learn more, see the [API Reference](https://openrouter.ai/docs/sdks/go/api-re
> This SDK is in **beta**. Pin to a specific version to avoid unexpected breaking changes:
>
> ```bash
> go get github.com/OpenRouterTeam/go-sdk@v0.9.73
> go get github.com/OpenRouterTeam/go-sdk@v0.9.74
> ```

<!-- No Summary [summary] -->
Expand Down
12 changes: 11 additions & 1 deletion RELEASES.md
Original file line number Diff line number Diff line change
Expand Up @@ -3248,4 +3248,14 @@ Based on:
### Generated
- [go v0.9.73] .
### Releases
- [Go v0.9.73] https://github.com/OpenRouterTeam/go-sdk/releases/tag/v0.9.73 - .
- [Go v0.9.73] https://github.com/OpenRouterTeam/go-sdk/releases/tag/v0.9.73 - .

## 2026-10-23 02:24:51
### Changes
Based on:
- OpenAPI Doc
- Speakeasy CLI 1.787.0 (2.914.0) https://github.com/speakeasy-api/speakeasy
### Generated
- [go v0.9.74] .
### Releases
- [Go v0.9.74] https://github.com/OpenRouterTeam/go-sdk/releases/tag/v0.9.74 - .
2 changes: 1 addition & 1 deletion doc.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ 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.9.73
go get github.com/OpenRouterTeam/go-sdk@v0.9.74

For full API documentation, visit: https://openrouter.ai/docs/client-sdks/go/overview

Expand Down
1 change: 1 addition & 0 deletions docs/sdks/generations/README.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,7 @@ func main() {
| sdkerrors.BadRequestResponseError | 400 | application/json |
| sdkerrors.UnauthorizedResponseError | 401 | application/json |
| sdkerrors.PaymentRequiredResponseError | 402 | application/json |
| sdkerrors.ForbiddenResponseError | 403 | application/json |
| sdkerrors.NotFoundResponseError | 404 | application/json |
| sdkerrors.TooManyRequestsResponseError | 429 | application/json |
| sdkerrors.InternalServerResponseError | 500 | application/json |
Expand Down
2 changes: 1 addition & 1 deletion example_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ func ExampleNew() {
openrouter.WithSecurity("your-api-key"),
)
fmt.Println(sdk.SDKVersion)
// Output: 0.9.73
// Output: 0.9.74
}

// Example demonstrates basic usage of the OpenRouter SDK for chat completions.
Expand Down
4 changes: 2 additions & 2 deletions examples/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -43,15 +43,15 @@ cd ../generation && go run .
Each example pins a released SDK version in `go.mod`:

```go
require github.com/OpenRouterTeam/go-sdk v0.9.73
require github.com/OpenRouterTeam/go-sdk v0.9.74
```

This should match the version in [README.md](../README.md) and `.speakeasy/gen.lock` `releaseVersion`. CI runs `scripts/bump-examples.sh` after releases to keep these in sync.

To use a different version:

```bash
go get github.com/OpenRouterTeam/go-sdk@v0.9.73
go get github.com/OpenRouterTeam/go-sdk@v0.9.74
go run .
```

Expand Down
21 changes: 21 additions & 0 deletions generations.go
Original file line number Diff line number Diff line change
Expand Up @@ -275,6 +275,27 @@ func (s *Generations) GetGeneration(ctx context.Context, id string, opts ...oper
return nil, err
}

return nil, &out
default:
rawBody, err := utils.ConsumeRawBody(httpRes)
if err != nil {
return nil, err
}
return nil, sdkerrors.NewAPIError(fmt.Sprintf("unknown content-type received: %s", httpRes.Header.Get("Content-Type")), httpRes.StatusCode, string(rawBody), httpRes)
}
case httpRes.StatusCode == 403:
switch {
case utils.MatchContentType(httpRes.Header.Get("Content-Type"), `application/json`):
rawBody, err := utils.ConsumeRawBody(httpRes)
if err != nil {
return nil, err
}

var out sdkerrors.ForbiddenResponseError
if err := utils.UnmarshalJsonFromResponseBody(bytes.NewBuffer(rawBody), &out, ""); err != nil {
return nil, err
}

return nil, &out
default:
rawBody, err := utils.ConsumeRawBody(httpRes)
Expand Down
18 changes: 2 additions & 16 deletions openrouter.go
Original file line number Diff line number Diff line change
Expand Up @@ -73,20 +73,6 @@ type OpenRouter struct {
Benchmarks *Benchmarks
// BYOK endpoints
BYOK *BYOK
// Stream a chat completion with an intern
// Sends a prompt to one of your interns and streams the reply as OpenAI-compatible server-sent events ending with `[DONE]`. The run executes on the intern, which may pause to ask you something. It then streams one `openrouter.provide_input` tool call and finishes with `finish_reason: "tool_calls"`, and the run stays open on the intern.
//
// Every response, whether it ends with `stop`, `tool_calls` or `error`, is followed by a final chunk with empty `choices` that carries `session_id`, then `data: [DONE]`. That chunk carries the `usage` the intern reported for the run, after `stop` or `error`, and `null` when the intern reported none. After `tool_calls` its `usage` is `null` because the turn is not over. Read through `[DONE]`: the `session_id` you need to reply arrives after the `tool_calls` finish chunk.
//
// To answer, send a second request with the same `session_id`, the assistant message echoing that tool call, and a `tool` message whose `tool_call_id` is the tool call id and whose `content` is the answer. The answer is delivered to the run that asked and the stream continues from where it paused. A question stays open for its interaction deadline (5 minutes by default) and the run is cancelled when that passes. Rejected replies do not extend the deadline.
//
// Closing the connection after the `[DONE]` that follows `finish_reason: "tool_calls"` keeps the run alive. Disconnecting while a response is still streaming cancels the run. The stream writes a `: keepalive` comment whenever nothing else has been written for 30 seconds, so a disconnect is noticed within that interval even while the intern is silent.
//
// A run the intern ends while you are still connected, by cancellation or by a deadline, ends the stream with a `finish_reason: "error"` chunk carrying `410` and reason `run_ended`, then the final empty-`choices` chunk and `[DONE]`. That error reports only an ending the intern confirmed. A connection that breaks without that confirmation ends with reason `stream_severed`, and a client that has already disconnected is promised no final event.
//
// Set `approval_mode` to `manual` to have the intern ask before approval-bearing tools such as the shell. Omitted, the run self-drives and consents on your behalf. The mode belongs to the run started by that prompt and must be repeated on later prompts.
//
// Available to interns programme members. Callers outside the programme receive `404` for every path under `/api/v1/interns`.
Chat *Chat
// Task classification market-share endpoints
Classifications *Classifications
Expand Down Expand Up @@ -233,9 +219,9 @@ func WithTimeout(timeout time.Duration) SDKOption {
// New creates a new instance of the SDK with the provided options
func New(opts ...SDKOption) *OpenRouter {
sdk := &OpenRouter{
SDKVersion: "0.9.73",
SDKVersion: "0.9.74",
sdkConfiguration: config.SDKConfiguration{
UserAgent: "speakeasy-sdk/go 0.9.73 2.914.0 1.0.0 github.com/OpenRouterTeam/go-sdk",
UserAgent: "speakeasy-sdk/go 0.9.74 2.914.0 1.0.0 github.com/OpenRouterTeam/go-sdk",
Globals: globals.Globals{},
ServerList: ServerList,
},
Expand Down