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
20 changes: 10 additions & 10 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: 1e710052958e02f0dcf0673f2a18a150
docChecksum: e0679e5a284910df5d3e3ac0ee007f80
docVersion: 1.0.0
speakeasyVersion: 1.787.0
generationVersion: 2.914.0
releaseVersion: 0.9.19
configChecksum: 6b1f31b92c372d991ab35dd71836a6b4
releaseVersion: 0.9.20
configChecksum: 325a5d0965070972fc9bf176d389cc4c
repoURL: https://github.com/OpenRouterTeam/go-sdk.git
installationURL: https://github.com/OpenRouterTeam/go-sdk
persistentEdits:
generation_id: cb39fe22-aae9-4468-b3c3-218ffc2db66d
pristine_commit_hash: c76773a21671361aef2077c85c63fc6a36ca8a57
pristine_tree_hash: 05f134fe8c97a61dfddd29e5e21821d1c57555d0
generation_id: 8ba0bdae-f657-4dc6-9d68-c5924aed81c1
pristine_commit_hash: 50cb333124075eb2f2bd0f6791fdf7fbb6f46cab
pristine_tree_hash: 44a355f319846f0dc4e2b7cfcaa793662000ca15
features:
go:
acceptHeaders: 2.81.2
Expand Down Expand Up @@ -105,8 +105,8 @@ trackedFiles:
pristine_git_object: 300f5ee15b73e7ecfd6b16e25d132ad1e4af8442
chat.go:
id: 81535ccb3ff5
last_write_checksum: sha1:3fe05c99a2a3f927bac689dc6dd9f0e6c51bc7b3
pristine_git_object: fedc9b46b5d2a7a4fc521b1af68b563cf4e116d8
last_write_checksum: sha1:bf12b147b40656ae0086e01601410f01ae94e039
pristine_git_object: 3ec067932ab585739098c417f40010f895bed95e
classifications.go:
id: 711367120ab6
last_write_checksum: sha1:1503d324707d56ecefdc2ec29ada40857bbff956
Expand Down Expand Up @@ -13361,8 +13361,8 @@ trackedFiles:
pristine_git_object: 5e3a2cdf8cb4ed4f5378b712293cba9c82074f16
openrouter.go:
id: 207ad004b774
last_write_checksum: sha1:192c8a66f4560a2853d4b596ef4233f3fed12c7f
pristine_git_object: edb55991440b48a25c1b08b0de5a9fc53294d3a9
last_write_checksum: sha1:2c615e8da0b5eed45ba80d026fb0516dccac2ad5
pristine_git_object: 302b1b8a7852a235c71e693f5987e175f565043d
optionalnullable/optionalnullable.go:
id: ce60f259ead3
last_write_checksum: sha1:d6aff1a420c31e025ea21d46cf056e305ae76fe8
Expand Down
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.19
version: 0.9.20
additionalDependencies: {}
baseErrorName: OpenRouterError
clientServerStatusCodesAsErrors: true
Expand Down
2 changes: 1 addition & 1 deletion .speakeasy/out.openapi.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -8831,7 +8831,7 @@ components:
items:
maxLength: 253
minLength: 1
pattern: '^[a-z0-9*]([a-z0-9*-]{0,61}[a-z0-9*])?(\.[a-z0-9*]([a-z0-9*-]{0,61}[a-z0-9*])?)*$'
pattern: '^(?![-.])(?!.*[-.]$)(?!.*(?:\.\.|\.-|-\.))(?!.*[^.]{64})[a-z0-9*.-]+$'
type: 'string'
maxItems: 50
minItems: 1
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:da24a30764520f9d081b7274222096914bccf90e13484b41e07ad7b3ec6ccf9c
sourceBlobDigest: sha256:3acb49e4b342ce1ce1deb505ab219ccae77035d8bd3f7e1aaa85c6c5641c84b1
sourceRevisionDigest: sha256:0909671576c07e1a0bd2f2acc73f91ed68fc2e5932008c9167b22c4c231b54db
sourceBlobDigest: sha256:073568cfc022ee43c266b54e5e31372f20f801686f0587de4fe572cf431968be
tags:
- latest
- 1.0.0
targets:
openrouter:
source: OpenRouter API
sourceNamespace: open-router-chat-completions-api
sourceRevisionDigest: sha256:da24a30764520f9d081b7274222096914bccf90e13484b41e07ad7b3ec6ccf9c
sourceBlobDigest: sha256:3acb49e4b342ce1ce1deb505ab219ccae77035d8bd3f7e1aaa85c6c5641c84b1
sourceRevisionDigest: sha256:0909671576c07e1a0bd2f2acc73f91ed68fc2e5932008c9167b22c4c231b54db
sourceBlobDigest: sha256:073568cfc022ee43c266b54e5e31372f20f801686f0587de4fe572cf431968be
codeSamplesNamespace: open-router-chat-completions-api-go-code-samples
codeSamplesRevisionDigest: sha256:6f5fcc2173f5061857f4f64d11b0009625fea5010bfbce084e29fbb86b0b8b6f
codeSamplesRevisionDigest: sha256:d05e11a65b54001a21f135bffbf8bf474293acaf7ba39e6571dba47219d955af
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.19
go get github.com/OpenRouterTeam/go-sdk@v0.9.20
```

**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.19
> go get github.com/OpenRouterTeam/go-sdk@v0.9.20
> ```

<!-- 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 @@ -2708,4 +2708,14 @@ Based on:
### Generated
- [go v0.9.19] .
### Releases
- [Go v0.9.19] https://github.com/OpenRouterTeam/go-sdk/releases/tag/v0.9.19 - .
- [Go v0.9.19] https://github.com/OpenRouterTeam/go-sdk/releases/tag/v0.9.19 - .

## 2026-10-02 12:57:42
### Changes
Based on:
- OpenAPI Doc
- Speakeasy CLI 1.787.0 (2.914.0) https://github.com/speakeasy-api/speakeasy
### Generated
- [go v0.9.20] .
### Releases
- [Go v0.9.20] https://github.com/OpenRouterTeam/go-sdk/releases/tag/v0.9.20 - .
14 changes: 14 additions & 0 deletions chat.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,20 @@ import (
"net/url"
)

// Chat - 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`.
type Chat struct {
rootSDK *OpenRouter
sdkConfiguration config.SDKConfiguration
Expand Down
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.19
go get github.com/OpenRouterTeam/go-sdk@v0.9.20

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

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.19
// Output: 0.9.20
}

// 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.19
require github.com/OpenRouterTeam/go-sdk v0.9.20
```

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.19
go get github.com/OpenRouterTeam/go-sdk@v0.9.20
go run .
```

Expand Down
18 changes: 16 additions & 2 deletions openrouter.go
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,20 @@ 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 @@ -220,9 +234,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.19",
SDKVersion: "0.9.20",
sdkConfiguration: config.SDKConfiguration{
UserAgent: "speakeasy-sdk/go 0.9.19 2.914.0 1.0.0 github.com/OpenRouterTeam/go-sdk",
UserAgent: "speakeasy-sdk/go 0.9.20 2.914.0 1.0.0 github.com/OpenRouterTeam/go-sdk",
Globals: globals.Globals{},
ServerList: ServerList,
},
Expand Down
Loading