diff --git a/.speakeasy/gen.lock b/.speakeasy/gen.lock index ab2356e0..3500c43e 100644 --- a/.speakeasy/gen.lock +++ b/.speakeasy/gen.lock @@ -1,18 +1,18 @@ lockVersion: 2.0.0 id: 9eea3e30-2722-4060-973b-57b7f1f75dc0 management: - docChecksum: f1c392b11e8e42e64a43b729f17f370a + docChecksum: 76847dddaf4195bb5389098ecd64c911 docVersion: 1.0.0 speakeasyVersion: 1.787.0 generationVersion: 2.914.0 - releaseVersion: 0.8.26 - configChecksum: a9952b90dcd56e5ec1a9d114903f4e85 + releaseVersion: 0.8.27 + configChecksum: ec18e8b7f0be26ec826bc9bdd004f47e repoURL: https://github.com/OpenRouterTeam/go-sdk.git installationURL: https://github.com/OpenRouterTeam/go-sdk persistentEdits: - generation_id: d27a70d4-61db-49fb-ba39-87634ffa07d8 - pristine_commit_hash: 9e75679540593d6f040c51aac0dba1ea2bd49aba - pristine_tree_hash: a604e644804e8b24d5f277bfbb61134a30ad9b22 + generation_id: dde7b26a-2dfe-402f-8710-1f99a3dddadb + pristine_commit_hash: ec7672cfeb8d02cf1ec82e270065df53745d1ac2 + pristine_tree_hash: 8dfa0b1fb374b87a80dca82275353857cd54c843 features: go: acceptHeaders: 2.81.2 @@ -100,8 +100,8 @@ trackedFiles: pristine_git_object: 300f5ee15b73e7ecfd6b16e25d132ad1e4af8442 chat.go: id: 81535ccb3ff5 - last_write_checksum: sha1:bf12b147b40656ae0086e01601410f01ae94e039 - pristine_git_object: 3ec067932ab585739098c417f40010f895bed95e + last_write_checksum: sha1:3fe05c99a2a3f927bac689dc6dd9f0e6c51bc7b3 + pristine_git_object: fedc9b46b5d2a7a4fc521b1af68b563cf4e116d8 classifications.go: id: 711367120ab6 last_write_checksum: sha1:1503d324707d56ecefdc2ec29ada40857bbff956 @@ -7620,8 +7620,8 @@ trackedFiles: pristine_git_object: 9abe56d206a750df1fe07c405a206502219594d7 docs/sdks/interns/README.mdx: id: 2f8a053ffe78 - last_write_checksum: sha1:3a7e76df30c85990cfa7583f78c35ab261e4ef2f - pristine_git_object: 76e6487ae177ec0123882e06700574e013c1ddff + last_write_checksum: sha1:a6520415ee3d7b0305d8d308e3943ee0fc979317 + pristine_git_object: a0196b54a931dc72c27656e0e09c69f927c64189 docs/sdks/models/README.mdx: id: 58f1ca464e0b last_write_checksum: sha1:14ffb11eb5c8db2aa311ac04b4e1e8bea0ca5528 @@ -7780,8 +7780,8 @@ trackedFiles: pristine_git_object: b32a14db51857aafab25498ba32fa2905c92b5d8 interns.go: id: aad99db3b05b - last_write_checksum: sha1:5eee48e0e491ad72ced445a21c6f15170e3f1455 - pristine_git_object: a5ec3370c1b12cedc2673f260fecc4fff28fd121 + last_write_checksum: sha1:8e96d922823b0e99cd3e50ce3badb6aa88ad795f + pristine_git_object: eb1e40a910e95a533907db763e712e5215084c60 models.go: id: 3af78faf181b last_write_checksum: sha1:8cc3e199c4b17ebc74642a4df902f06f8daeb2c7 @@ -11100,8 +11100,8 @@ trackedFiles: pristine_git_object: 5e3a2cdf8cb4ed4f5378b712293cba9c82074f16 openrouter.go: id: 207ad004b774 - last_write_checksum: sha1:71c6b91448599257ff743a16c35c972c0af04fcb - pristine_git_object: 358bf27cbc622e3ff89bb538c6e89b23bdd819fd + last_write_checksum: sha1:a4fa7f2e5c6a04fcaf2f42a157dfaaff9c733842 + pristine_git_object: b7af4d8bb416299e80569f78a9cdc3f2d51088aa optionalnullable/optionalnullable.go: id: ce60f259ead3 last_write_checksum: sha1:d6aff1a420c31e025ea21d46cf056e305ae76fe8 @@ -14429,4 +14429,6 @@ examples: "500": application/json: {"error": {"code": 404, "message": "Intern not found"}} examplesVersion: 1.0.2 -releaseNotes: "## Go SDK Changes:\n* `OpenRouter.Alpha.Decisions.Create()`: \n * `request.Request.Provider` **Changed**\n* `OpenRouter.Tts.CreateSpeech()`: \n * `request.Request.Provider.Options.Scaledown` **Added**\n* `OpenRouter.Stt.CreateTranscription()`: \n * `request.Request.Provider.Options.Scaledown` **Added**\n* `OpenRouter.Byok.List()`: \n * `request.Provider` **Changed**\n * `response.Data[].Provider.Enum(scaledown)` **Added**\n* `OpenRouter.Byok.Create()`: \n * `request.Request.Provider.Enum(scaledown)` **Added**\n * `response.Data.Provider.Enum(scaledown)` **Added**\n* `OpenRouter.Byok.Get()`: `response.Data.Provider.Enum(scaledown)` **Added**\n* `OpenRouter.Byok.Update()`: `response.Data.Provider.Enum(scaledown)` **Added**\n* `OpenRouter.Chat.Send()`: \n * `request.ChatRequest.Provider` **Changed**\n* `OpenRouter.Embeddings.Generate()`: \n * `request.Request.Provider` **Changed**\n* `OpenRouter.Endpoints.ListZdrEndpoints()`: `response.Data[].ProviderName.Enum(scaleDown)` **Added**\n* `OpenRouter.Endpoints.List()`: `response.Data.Endpoints[].ProviderName.Enum(scaleDown)` **Added**\n* `OpenRouter.Generations.GetGeneration()`: `response.Data.ProviderResponses[].ProviderName.Enum(scaleDown)` **Added**\n* `OpenRouter.Images.Generate()`: \n * `request.Request.Provider` **Changed**\n* `OpenRouter.Presets.CreatePresetsChatCompletions()`: \n * `request.ChatRequest.Provider` **Changed**\n* `OpenRouter.Presets.CreatePresetsMessages()`: \n * `request.MessagesRequest.Provider` **Changed**\n* `OpenRouter.Presets.CreatePresetsResponses()`: \n * `request.ResponsesRequest.Provider` **Changed**\n* `OpenRouter.Rerank.Rerank()`: \n * `request.Request.Provider` **Changed**\n* `OpenRouter.Responses.Send()`: \n * `request.ResponsesRequest.Provider` **Changed**\n* `OpenRouter.Beta.Responses.Send()`: \n * `request.ResponsesRequest.Provider` **Changed**\n* `OpenRouter.SystemOne.Create()`: \n * `request.Request.Provider` **Changed**\n* `OpenRouter.VideoGeneration.Generate()`: \n * `request.Request.Provider.Options.Scaledown` **Added**\n" +releaseNotes: | + ## Go SDK Changes: + * `OpenRouter.Interns.GetInternDaemonAccess()`: `error.status[429]` **Removed** (Breaking ⚠️) diff --git a/.speakeasy/gen.yaml b/.speakeasy/gen.yaml index 04eccf75..0cd91043 100644 --- a/.speakeasy/gen.yaml +++ b/.speakeasy/gen.yaml @@ -36,7 +36,7 @@ generation: documentation: mintlify preApplyUnionDiscriminators: true go: - version: 0.8.26 + version: 0.8.27 additionalDependencies: {} baseErrorName: OpenRouterError clientServerStatusCodesAsErrors: true diff --git a/.speakeasy/out.openapi.yaml b/.speakeasy/out.openapi.yaml index b79dce89..3a3773c2 100644 --- a/.speakeasy/out.openapi.yaml +++ b/.speakeasy/out.openapi.yaml @@ -37615,7 +37615,7 @@ paths: x-speakeasy-name-override: 'chat' /interns/{internId}/daemon-access: get: - description: 'Returns the origin and daemon token that attach `ori tui --host` to one visible, running intern. The token is a credential: the response is sent with `Cache-Control: no-store`, each reveal is logged by caller and intern, and a caller may make 10 reveals per minute. The API key selects the caller, workspace and visible interns. There is no default workspace fallback. Requests on regional hostnames such as `eu.openrouter.ai` are refused. [API key](/docs/api-reference/authentication) required.' + description: 'Returns the origin and daemon token that attach `ori tui --host` to one visible, running intern. The token is a credential: the response is sent with `Cache-Control: no-store`, and each reveal is logged by caller and intern. The API key selects the caller, workspace and visible interns. There is no default workspace fallback. Requests on regional hostnames such as `eu.openrouter.ai` are refused. [API key](/docs/api-reference/authentication) required.' operationId: 'getInternDaemonAccess' parameters: - description: 'ID of an intern visible to the authenticated API key.' @@ -37693,19 +37693,6 @@ paths: schema: $ref: '#/components/schemas/InternLifecycleError' description: 'The intern cannot be attached to. `metadata.reason` is `intern_not_running`, `intern_unreachable` when it has no usable address yet, or `intern_needs_restart` when it was provisioned before daemon access was available.' - '429': - content: - application/json: - example: - error: - code: 429 - message: 'Too many token reveals. Please wait a moment.' - metadata: - reason: 'rate_limited' - retryable: true - schema: - $ref: '#/components/schemas/InternLifecycleError' - description: 'The caller made more than 10 reveals in the last minute. Wait for `Retry-After` seconds.' '500': content: application/json: diff --git a/.speakeasy/workflow.lock b/.speakeasy/workflow.lock index c0be10c2..7f2425ec 100644 --- a/.speakeasy/workflow.lock +++ b/.speakeasy/workflow.lock @@ -2,8 +2,8 @@ speakeasyVersion: 1.787.0 sources: OpenRouter API: sourceNamespace: open-router-chat-completions-api - sourceRevisionDigest: sha256:d0999e8939d94971d792750a3f8ee1c688c40905a51b94c3c1b9bbc8951a2a98 - sourceBlobDigest: sha256:904a5eccabef2f8d817f81fb614cf5cefd0f6d2ed19b467608154e72fc0b4084 + sourceRevisionDigest: sha256:10d80fa11ae336d9888d7f3df46d6dc9243c5045e32a3d18fad2806fee5e2f9f + sourceBlobDigest: sha256:1e0ded936cabba0ea8a5bdef6d43c48b790415ca4dad32509120e5011ffc776e tags: - latest - 1.0.0 @@ -11,10 +11,10 @@ targets: openrouter: source: OpenRouter API sourceNamespace: open-router-chat-completions-api - sourceRevisionDigest: sha256:d0999e8939d94971d792750a3f8ee1c688c40905a51b94c3c1b9bbc8951a2a98 - sourceBlobDigest: sha256:904a5eccabef2f8d817f81fb614cf5cefd0f6d2ed19b467608154e72fc0b4084 + sourceRevisionDigest: sha256:10d80fa11ae336d9888d7f3df46d6dc9243c5045e32a3d18fad2806fee5e2f9f + sourceBlobDigest: sha256:1e0ded936cabba0ea8a5bdef6d43c48b790415ca4dad32509120e5011ffc776e codeSamplesNamespace: open-router-chat-completions-api-go-code-samples - codeSamplesRevisionDigest: sha256:c21c5832deee7ebd8d0b5d388ab2066936c4c1315a206c1a44684280025380d2 + codeSamplesRevisionDigest: sha256:1ff5b5e0e84b7eb334a7b3e309058fc79c47d80549b277e13f49bd2ffb41ea33 workflow: workflowVersion: 1.0.0 speakeasyVersion: 1.787.0 diff --git a/OVERVIEW.md b/OVERVIEW.md index a7fa47a2..8c820220 100644 --- a/OVERVIEW.md +++ b/OVERVIEW.md @@ -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.8.26 +go get github.com/OpenRouterTeam/go-sdk@v0.8.27 ``` **Requirements:** Go 1.25 or higher diff --git a/README.md b/README.md index b3381fce..50fa020c 100644 --- a/README.md +++ b/README.md @@ -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.8.26 +> go get github.com/OpenRouterTeam/go-sdk@v0.8.27 > ``` diff --git a/RELEASES.md b/RELEASES.md index 5c2c53b6..d1f961f4 100644 --- a/RELEASES.md +++ b/RELEASES.md @@ -2418,4 +2418,14 @@ Based on: ### Generated - [go v0.8.26] . ### Releases -- [Go v0.8.26] https://github.com/OpenRouterTeam/go-sdk/releases/tag/v0.8.26 - . \ No newline at end of file +- [Go v0.8.26] https://github.com/OpenRouterTeam/go-sdk/releases/tag/v0.8.26 - . + +## 2026-09-25 10:14:30 +### Changes +Based on: +- OpenAPI Doc +- Speakeasy CLI 1.787.0 (2.914.0) https://github.com/speakeasy-api/speakeasy +### Generated +- [go v0.8.27] . +### Releases +- [Go v0.8.27] https://github.com/OpenRouterTeam/go-sdk/releases/tag/v0.8.27 - . \ No newline at end of file diff --git a/chat.go b/chat.go index 3ec06793..fedc9b46 100644 --- a/chat.go +++ b/chat.go @@ -18,20 +18,6 @@ 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 diff --git a/doc.go b/doc.go index 4d770b12..93f184fe 100644 --- a/doc.go +++ b/doc.go @@ -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.8.26 + go get github.com/OpenRouterTeam/go-sdk@v0.8.27 For full API documentation, visit: https://openrouter.ai/docs/client-sdks/go/overview diff --git a/docs/sdks/interns/README.mdx b/docs/sdks/interns/README.mdx index 76e6487a..a0196b54 100644 --- a/docs/sdks/interns/README.mdx +++ b/docs/sdks/interns/README.mdx @@ -306,7 +306,7 @@ func main() { ## GetInternDaemonAccess -Returns the origin and daemon token that attach `ori tui --host` to one visible, running intern. The token is a credential: the response is sent with `Cache-Control: no-store`, each reveal is logged by caller and intern, and a caller may make 10 reveals per minute. The API key selects the caller, workspace and visible interns. There is no default workspace fallback. Requests on regional hostnames such as `eu.openrouter.ai` are refused. [API key](/docs/api-reference/authentication) required. +Returns the origin and daemon token that attach `ori tui --host` to one visible, running intern. The token is a credential: the response is sent with `Cache-Control: no-store`, and each reveal is logged by caller and intern. The API key selects the caller, workspace and visible interns. There is no default workspace fallback. Requests on regional hostnames such as `eu.openrouter.ai` are refused. [API key](/docs/api-reference/authentication) required. ### Example Usage @@ -353,7 +353,7 @@ func main() { | Error Type | Status Code | Content Type | | ------------------------------ | ------------------------------ | ------------------------------ | -| sdkerrors.InternLifecycleError | 401, 403, 404, 408, 409, 429 | application/json | +| sdkerrors.InternLifecycleError | 401, 403, 404, 408, 409 | application/json | | sdkerrors.InternLifecycleError | 500 | application/json | | sdkerrors.APIError | 4XX, 5XX | \*/\* | diff --git a/example_test.go b/example_test.go index 825337ea..4adc46be 100644 --- a/example_test.go +++ b/example_test.go @@ -18,7 +18,7 @@ func ExampleNew() { openrouter.WithSecurity("your-api-key"), ) fmt.Println(sdk.SDKVersion) - // Output: 0.8.26 + // Output: 0.8.27 } // Example demonstrates basic usage of the OpenRouter SDK for chat completions. diff --git a/examples/README.md b/examples/README.md index 040ae9b4..068aef1c 100644 --- a/examples/README.md +++ b/examples/README.md @@ -43,7 +43,7 @@ cd ../generation && go run . Each example pins a released SDK version in `go.mod`: ```go -require github.com/OpenRouterTeam/go-sdk v0.8.26 +require github.com/OpenRouterTeam/go-sdk v0.8.27 ``` 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. @@ -51,7 +51,7 @@ This should match the version in [README.md](../README.md) and `.speakeasy/gen.l To use a different version: ```bash -go get github.com/OpenRouterTeam/go-sdk@v0.8.26 +go get github.com/OpenRouterTeam/go-sdk@v0.8.27 go run . ``` diff --git a/interns.go b/interns.go index a5ec3370..eb1e40a9 100644 --- a/interns.go +++ b/interns.go @@ -1394,7 +1394,7 @@ func (s *Interns) UpdateIntern(ctx context.Context, internID string, updateInter } // GetInternDaemonAccess - Get an intern's daemon access -// Returns the origin and daemon token that attach `ori tui --host` to one visible, running intern. The token is a credential: the response is sent with `Cache-Control: no-store`, each reveal is logged by caller and intern, and a caller may make 10 reveals per minute. The API key selects the caller, workspace and visible interns. There is no default workspace fallback. Requests on regional hostnames such as `eu.openrouter.ai` are refused. [API key](/docs/api-reference/authentication) required. +// Returns the origin and daemon token that attach `ori tui --host` to one visible, running intern. The token is a credential: the response is sent with `Cache-Control: no-store`, and each reveal is logged by caller and intern. The API key selects the caller, workspace and visible interns. There is no default workspace fallback. Requests on regional hostnames such as `eu.openrouter.ai` are refused. [API key](/docs/api-reference/authentication) required. // // If set, this operation will use [Security.APIKey] from the global security. func (s *Interns) GetInternDaemonAccess(ctx context.Context, internID string, opts ...operations.Option) (*components.InternDaemonAccess, error) { @@ -1589,8 +1589,6 @@ func (s *Interns) GetInternDaemonAccess(ctx context.Context, internID string, op case httpRes.StatusCode == 408: fallthrough case httpRes.StatusCode == 409: - fallthrough - case httpRes.StatusCode == 429: switch { case utils.MatchContentType(httpRes.Header.Get("Content-Type"), `application/json`): rawBody, err := utils.ConsumeRawBody(httpRes) diff --git a/openrouter.go b/openrouter.go index 358bf27c..b7af4d8b 100644 --- a/openrouter.go +++ b/openrouter.go @@ -71,6 +71,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 @@ -212,9 +226,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.8.26", + SDKVersion: "0.8.27", sdkConfiguration: config.SDKConfiguration{ - UserAgent: "speakeasy-sdk/go 0.8.26 2.914.0 1.0.0 github.com/OpenRouterTeam/go-sdk", + UserAgent: "speakeasy-sdk/go 0.8.27 2.914.0 1.0.0 github.com/OpenRouterTeam/go-sdk", Globals: globals.Globals{}, ServerList: ServerList, },