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
41 changes: 23 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: 1465979ab89a0f1af12ea84cd1e18672
docChecksum: 3d5ada548d4f46175e971e318342a856
docVersion: 1.0.0
speakeasyVersion: 1.787.0
generationVersion: 2.914.0
releaseVersion: 0.9.38
configChecksum: 8fb9aabef9178e100ca5822bb6f64acc
releaseVersion: 0.9.39
configChecksum: 822e38092ee4090725a96fbe6b60d0aa
repoURL: https://github.com/OpenRouterTeam/go-sdk.git
installationURL: https://github.com/OpenRouterTeam/go-sdk
persistentEdits:
generation_id: 5c69bd42-3f31-4ee2-baa1-e4a139f86967
pristine_commit_hash: 7c448c2e1f828419c563575dd1340056a5103ecb
pristine_tree_hash: 6a1c13f284155900994d26522933c1612555810e
generation_id: 8b8d2c82-b892-4488-8c68-a271483fd28e
pristine_commit_hash: b47cd5df18ec0830f5d3e30f7f52552e90f15b2e
pristine_tree_hash: ffa988c274b1cc5b7ea18c368d397cbc2aabd2ea
features:
go:
acceptHeaders: 2.81.2
Expand Down Expand Up @@ -81,8 +81,8 @@ trackedFiles:
pristine_git_object: 19cafdf94c8623199653cce8f3d90e2dceec2348
apikeys.go:
id: 8baafe5dc76e
last_write_checksum: sha1:9dbffe740376eddece85f84cf3bba452f5a18b87
pristine_git_object: d3ad9c42e034c25ec87f33a321749d6cd0346185
last_write_checksum: sha1:d285e2245720832622d899c9dcf76727ac695365
pristine_git_object: add418e98163433ad044968d604c1d656d015a1a
batch.go:
id: f0580a64f821
last_write_checksum: sha1:e665d74307f94d032221149976b1d0c7850f3e24
Expand All @@ -105,8 +105,8 @@ trackedFiles:
pristine_git_object: a2e44316e3d85259a78edd2f1f8443abb967892c
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
Expand Down Expand Up @@ -9033,8 +9033,8 @@ trackedFiles:
pristine_git_object: b77a48faeaa1f64c56b15a2fe3ed5340a6f13979
docs/models/operations/updatekeysrequestbody.mdx:
id: 15d031815eeb
last_write_checksum: sha1:bd3b2086c89cc71df440aeb4ae5de77ff9f46e86
pristine_git_object: d311f277d4315f2d19ea78a4512b12f14ba477c5
last_write_checksum: sha1:51615535f75bea9360d46f81b01194c6279772e2
pristine_git_object: b00baa04a4c26ddf389a8b483523254df932734a
docs/models/operations/updatekeysresponse.mdx:
id: 3d4ab9b1b401
last_write_checksum: sha1:e4729294e2471f5274941d317748722c77a7d986
Expand Down Expand Up @@ -9229,8 +9229,8 @@ trackedFiles:
pristine_git_object: 84d83302a14fcf3cfda0caff3b3d2d5d5028bc71
docs/sdks/apikeys/README.mdx:
id: 27fcaae1c346
last_write_checksum: sha1:166303b0b79c6059000ceeb6095b60d540cc9281
pristine_git_object: 9b084cf944397dd1ec6278cefdbe9c076ba702af
last_write_checksum: sha1:5366a46528638b28fb4aceb7b5de872fdd873b2c
pristine_git_object: f2d671a76d5e8defce6bc68eefbefe186d2cb53b
docs/sdks/batch/README.mdx:
id: e367aa4f4295
last_write_checksum: sha1:3c3f1d13862f80193d7d2a3e984df38a9c906d91
Expand Down Expand Up @@ -13361,8 +13361,8 @@ trackedFiles:
pristine_git_object: 1e78062abafa3b68c339889d8e74866e6de050eb
models/operations/updatekeys.go:
id: b9d605aa7df2
last_write_checksum: sha1:ef4dc8bd7a48dce98d95a018b7683da5ad5c86b9
pristine_git_object: 679c1d327f92aa423532292274ba164b6a43a50c
last_write_checksum: sha1:2f80e2c4ef839193b19b7b2fee2d0051cd285a77
pristine_git_object: 2d402fa190980bdf5179d268d004131314b1d4a3
models/operations/updateobservabilitydestination.go:
id: d288ea102434
last_write_checksum: sha1:b4741c8163851ead75a9b63f1272cf4c1b5195cc
Expand Down Expand Up @@ -13509,8 +13509,8 @@ trackedFiles:
pristine_git_object: 5e3a2cdf8cb4ed4f5378b712293cba9c82074f16
openrouter.go:
id: 207ad004b774
last_write_checksum: sha1:173e2ec8731cc8c200d8d3debc8bfd4b1172a8fb
pristine_git_object: 0195edceb6aba3d5dd9c8a36628cc1ade42f047c
last_write_checksum: sha1:de8d47cdaea09f7fadcb0ca083560ee10cf6721b
pristine_git_object: 9a5419707442ca5d29b9ad3d2e7bbf388ba2c656
optionalnullable/optionalnullable.go:
id: ce60f259ead3
last_write_checksum: sha1:d6aff1a420c31e025ea21d46cf056e305ae76fe8
Expand Down Expand Up @@ -13889,6 +13889,10 @@ examples:
application/json: {"error": {"code": 429, "message": "Rate limit exceeded"}}
"500":
application/json: {"error": {"code": 500, "message": "Internal Server Error"}}
"403":
application/json: {"error": {"code": 403, "message": "Only management keys can perform this operation"}}
"409":
application/json: {"error": {"code": 409, "message": "Resource conflict. Please try again later."}}
invalid_parameters:
parameters:
path:
Expand Down Expand Up @@ -17559,3 +17563,4 @@ examples:
"500":
application/json: {"error": {"code": 404, "message": "Intern not found"}}
examplesVersion: 1.0.2
releaseNotes: "## Go SDK Changes:\n* `OpenRouter.ApiKeys.Update()`: \n * `request.RequestBody.WorkspaceId` **Added**\n * `error` **Changed**\n"
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.38
version: 0.9.39
additionalDependencies: {}
baseErrorName: OpenRouterError
clientServerStatusCodesAsErrors: true
Expand Down
29 changes: 27 additions & 2 deletions .speakeasy/out.openapi.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -44488,7 +44488,7 @@ paths:
- 'API Keys'
x-speakeasy-name-override: 'get'
patch:
description: "Update an existing API key. Authenticate with a [management key](/docs/guides/overview/auth/management-api-keys).\n\n<Warning>\nYou can't change `workspace_id` through the API. The request body accepts only the fields listed below, and unrecognized fields are ignored. To move a key to another workspace, use the OpenRouter dashboard. If the body contains none of the accepted fields, the request fails with `400` and the message `No update fields provided`.\n</Warning>"
description: "Update an existing API key. Authenticate with a [management key](/docs/guides/overview/auth/management-api-keys).\n\nSet `workspace_id` to move the key to another workspace. The key keeps its value, and any other fields in the same request are applied atomically with the move. Guardrail selections move with the key; other workspace-scoped settings (presets, BYOK keys, broadcast destinations, routing rules) do not. A move into or out of a HIPAA workspace is refused with `403`. In an organization, if the key's creator is not a member of a non-default target workspace, the request fails with `409`; add them to the workspace first.\n\n<Warning>\nThe request body accepts only the fields listed below, and unrecognized fields are ignored. If the body contains none of the accepted fields, the request fails with `400` and the message `No update fields provided`.\n</Warning>"
operationId: 'updateKeys'
parameters:
- description: 'The hash identifier of the API key to update'
Expand Down Expand Up @@ -44547,6 +44547,11 @@ paths:
description: 'New name for the API key'
example: 'Updated API Key Name'
type: 'string'
workspace_id:
description: 'Move the API key to this workspace. The key keeps its value; guardrail selections move with it, while other workspace-scoped settings (presets, BYOK keys, broadcast destinations, routing rules) do not. Sending the key''s current workspace is a no-op.'
example: '0df9e665-d932-5740-b2c7-b52af166bc11'
format: 'uuid'
type: 'string'
type: 'object'
required: true
responses:
Expand Down Expand Up @@ -44790,7 +44795,7 @@ paths:
code: 400
message: 'Invalid request parameters'
no_update_fields:
description: 'Returned when the body contains none of the accepted fields, for example `{"workspace_id": "..."}`. `workspace_id` can''t be changed through the API.'
description: 'Returned when the body contains none of the accepted fields, for example `{"label": "..."}`.'
summary: 'No accepted fields in the request body'
value:
error:
Expand All @@ -44809,6 +44814,16 @@ paths:
schema:
$ref: '#/components/schemas/UnauthorizedResponse'
description: 'Unauthorized - Authentication required or invalid credentials'
'403':
content:
application/json:
example:
error:
code: 403
message: 'Only management keys can perform this operation'
schema:
$ref: '#/components/schemas/ForbiddenResponse'
description: 'Forbidden - Authentication successful but insufficient permissions'
'404':
content:
application/json:
Expand All @@ -44819,6 +44834,16 @@ paths:
schema:
$ref: '#/components/schemas/NotFoundResponse'
description: 'Not Found - Resource does not exist'
'409':
content:
application/json:
example:
error:
code: 409
message: 'The API key creator is not a member of the target workspace. Add them to the workspace, then retry.'
schema:
$ref: '#/components/schemas/ConflictResponse'
description: 'Conflict - Resource conflict or concurrent modification'
'429':
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:4b2aebbb5fbbb0d0ebf5985530146f12b6435191613d78c3e560aef531f9d5fd
sourceBlobDigest: sha256:e9454aee071b3f11a3f17e237b854da3e739b749d8eafbb104de54e887aad327
sourceRevisionDigest: sha256:c0b72a3547a9bab0db7a313b62416c81d0e027e761b1d29f69ae43630bbf59da
sourceBlobDigest: sha256:5c3eb90656b98ad8b0c96d72d5492d7ef61aa94705134dfa68aa435da6973c94
tags:
- latest
- 1.0.0
targets:
openrouter:
source: OpenRouter API
sourceNamespace: open-router-chat-completions-api
sourceRevisionDigest: sha256:4b2aebbb5fbbb0d0ebf5985530146f12b6435191613d78c3e560aef531f9d5fd
sourceBlobDigest: sha256:e9454aee071b3f11a3f17e237b854da3e739b749d8eafbb104de54e887aad327
sourceRevisionDigest: sha256:c0b72a3547a9bab0db7a313b62416c81d0e027e761b1d29f69ae43630bbf59da
sourceBlobDigest: sha256:5c3eb90656b98ad8b0c96d72d5492d7ef61aa94705134dfa68aa435da6973c94
codeSamplesNamespace: open-router-chat-completions-api-go-code-samples
codeSamplesRevisionDigest: sha256:3934dcb1896768fee9763e81a907cc7cde24dd4e417393a2907e5617aba5dd85
codeSamplesRevisionDigest: sha256:71af6dcbbccf798bee36017e181ae306ba04b2db592073ca296d43c64e78f41d
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.38
go get github.com/OpenRouterTeam/go-sdk@v0.9.39
```

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

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

## 2026-10-09 15:16:58
### Changes
Based on:
- OpenAPI Doc
- Speakeasy CLI 1.787.0 (2.914.0) https://github.com/speakeasy-api/speakeasy
### Generated
- [go v0.9.39] .
### Releases
- [Go v0.9.39] https://github.com/OpenRouterTeam/go-sdk/releases/tag/v0.9.39 - .
46 changes: 45 additions & 1 deletion apikeys.go
Original file line number Diff line number Diff line change
Expand Up @@ -1485,8 +1485,10 @@ func (s *APIKeys) Get(ctx context.Context, hash string, opts ...operations.Optio
// Update an API key
// Update an existing API key. Authenticate with a [management key](/docs/guides/overview/auth/management-api-keys).
//
// Set `workspace_id` to move the key to another workspace. The key keeps its value, and any other fields in the same request are applied atomically with the move. Guardrail selections move with the key; other workspace-scoped settings (presets, BYOK keys, broadcast destinations, routing rules) do not. A move into or out of a HIPAA workspace is refused with `403`. In an organization, if the key's creator is not a member of a non-default target workspace, the request fails with `409`; add them to the workspace first.
//
// <Warning>
// You can't change `workspace_id` through the API. The request body accepts only the fields listed below, and unrecognized fields are ignored. To move a key to another workspace, use the OpenRouter dashboard. If the body contains none of the accepted fields, the request fails with `400` and the message `No update fields provided`.
// The request body accepts only the fields listed below, and unrecognized fields are ignored. If the body contains none of the accepted fields, the request fails with `400` and the message `No update fields provided`.
// </Warning>
func (s *APIKeys) Update(ctx context.Context, hash string, requestBody operations.UpdateKeysRequestBody, opts ...operations.Option) (*operations.UpdateKeysResponse, error) {
request := operations.UpdateKeysRequest{
Expand Down Expand Up @@ -1713,6 +1715,27 @@ func (s *APIKeys) Update(ctx context.Context, hash string, requestBody operation
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 All @@ -1734,6 +1757,27 @@ func (s *APIKeys) Update(ctx context.Context, hash string, requestBody operation
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 == 409:
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.ConflictResponseError
if err := utils.UnmarshalJsonFromResponseBody(bytes.NewBuffer(rawBody), &out, ""); err != nil {
return nil, err
}

return nil, &out
default:
rawBody, err := utils.ConsumeRawBody(httpRes)
Expand Down
14 changes: 0 additions & 14 deletions chat.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
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.38
go get github.com/OpenRouterTeam/go-sdk@v0.9.39

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

Expand Down
Loading