Skip to content

Commit 5d06b0a

Browse files
committed
add open enums, server selection, update description
1 parent 540701c commit 5d06b0a

16 files changed

+128
-61
lines changed

.speakeasy/gen.lock

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,12 @@
11
lockVersion: 2.0.0
22
id: 03e733ff-14c6-48f8-87a5-37a1a4588594
33
management:
4-
docChecksum: f629b0ca18ec064975608b5eea7aebfd
4+
docChecksum: 7849dd264d8d3676743d325682310ed7
55
docVersion: 1.0.0
6-
speakeasyVersion: 1.617.1
7-
generationVersion: 2.701.8
6+
speakeasyVersion: 1.618.1
7+
generationVersion: 2.702.0
88
releaseVersion: 0.1.0
9-
configChecksum: ee7ed66772b5663ad6d381d1b4142fe2
9+
configChecksum: 9b2fc6a03dd7103d87270af55bb29a50
1010
features:
1111
python:
1212
acceptHeaders: 3.0.0
@@ -27,11 +27,13 @@ features:
2727
methodArguments: 1.0.2
2828
nameOverrides: 3.0.1
2929
nullables: 1.0.1
30+
openEnums: 1.0.1
3031
responseFormat: 1.0.1
3132
retries: 3.0.2
3233
sdkHooks: 1.1.0
3334
serverEvents: 1.0.9
3435
serverEventsSentinels: 0.1.0
36+
serverIDs: 3.0.0
3537
unions: 3.0.4
3638
generatedFiles:
3739
- .devcontainer/README.md

.speakeasy/gen.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ python:
3939
baseErrorName: OpenRouterError
4040
clientServerStatusCodesAsErrors: true
4141
defaultErrorName: OpenRouterDefaultError
42-
description: Python Client SDK Generated by Speakeasy.
42+
description: The OpenRouter Python SDK.
4343
enableCustomCodeRegions: true
4444
enumFormat: union
4545
envVarPrefix: OPENROUTER

.speakeasy/in.openapi.yaml

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ info:
1212
url: https://opensource.org/licenses/MIT
1313
servers:
1414
- url: https://{provider_url}/api/v1
15+
x-speakeasy-server-id: production
1516
variables:
1617
provider_url:
1718
default: openrouter.ai
@@ -77,6 +78,7 @@ components:
7778
type: string
7879
nullable: true
7980
format:
81+
x-speakeasy-unknown-values: allow
8082
type: string
8183
nullable: true
8284
enum:
@@ -103,6 +105,7 @@ components:
103105
type: string
104106
nullable: true
105107
format:
108+
x-speakeasy-unknown-values: allow
106109
type: string
107110
nullable: true
108111
enum:
@@ -133,6 +136,7 @@ components:
133136
type: string
134137
nullable: true
135138
format:
139+
x-speakeasy-unknown-values: allow
136140
type: string
137141
nullable: true
138142
enum:
@@ -351,6 +355,7 @@ components:
351355
type: object
352356
properties:
353357
finish_reason:
358+
x-speakeasy-unknown-values: allow
354359
type: string
355360
nullable: true
356361
enum:
@@ -541,6 +546,7 @@ components:
541546
delta:
542547
$ref: '#/components/schemas/ChatCompletionChunkChoiceDelta'
543548
finish_reason:
549+
x-speakeasy-unknown-values: allow
544550
type: string
545551
nullable: true
546552
enum:
@@ -649,6 +655,7 @@ components:
649655
type: string
650656
description: Base64 encoded audio data
651657
format:
658+
x-speakeasy-unknown-values: allow
652659
type: string
653660
enum:
654661
- wav

.speakeasy/out.openapi.yaml

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ info:
1212
url: https://opensource.org/licenses/MIT
1313
servers:
1414
- url: https://{provider_url}/api/v1
15+
x-speakeasy-server-id: production
1516
variables:
1617
provider_url:
1718
default: openrouter.ai
@@ -77,6 +78,7 @@ components:
7778
type: string
7879
nullable: true
7980
format:
81+
x-speakeasy-unknown-values: allow
8082
type: string
8183
nullable: true
8284
enum:
@@ -103,6 +105,7 @@ components:
103105
type: string
104106
nullable: true
105107
format:
108+
x-speakeasy-unknown-values: allow
106109
type: string
107110
nullable: true
108111
enum:
@@ -133,6 +136,7 @@ components:
133136
type: string
134137
nullable: true
135138
format:
139+
x-speakeasy-unknown-values: allow
136140
type: string
137141
nullable: true
138142
enum:
@@ -351,6 +355,7 @@ components:
351355
type: object
352356
properties:
353357
finish_reason:
358+
x-speakeasy-unknown-values: allow
354359
type: string
355360
nullable: true
356361
enum:
@@ -541,6 +546,7 @@ components:
541546
delta:
542547
$ref: '#/components/schemas/ChatCompletionChunkChoiceDelta'
543548
finish_reason:
549+
x-speakeasy-unknown-values: allow
544550
type: string
545551
nullable: true
546552
enum:
@@ -649,6 +655,7 @@ components:
649655
type: string
650656
description: Base64 encoded audio data
651657
format:
658+
x-speakeasy-unknown-values: allow
652659
type: string
653660
enum:
654661
- wav

.speakeasy/workflow.lock

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,20 +1,20 @@
1-
speakeasyVersion: 1.617.1
1+
speakeasyVersion: 1.618.1
22
sources:
33
OpenRouter Chat Completions API:
44
sourceNamespace: open-router-chat-completions-api
5-
sourceRevisionDigest: sha256:a7746404e672bbb6dcd8354532d0c627d24522844c39d58011d4cd9c7e8ebd20
6-
sourceBlobDigest: sha256:67c793fef9c039a2c351fc6ba7ed9a6119059023fe3fbd1022645d7494c2c63c
5+
sourceRevisionDigest: sha256:74ae52780983745871d33efc788abba37d1d8b271f358771b180ddb8546d6f7f
6+
sourceBlobDigest: sha256:2fd2132e64b77adae1fc045512364d6517f47916c553e757226e5b9012d2170d
77
tags:
88
- latest
99
- 1.0.0
1010
targets:
1111
open-router:
1212
source: OpenRouter Chat Completions API
1313
sourceNamespace: open-router-chat-completions-api
14-
sourceRevisionDigest: sha256:a7746404e672bbb6dcd8354532d0c627d24522844c39d58011d4cd9c7e8ebd20
15-
sourceBlobDigest: sha256:67c793fef9c039a2c351fc6ba7ed9a6119059023fe3fbd1022645d7494c2c63c
14+
sourceRevisionDigest: sha256:74ae52780983745871d33efc788abba37d1d8b271f358771b180ddb8546d6f7f
15+
sourceBlobDigest: sha256:2fd2132e64b77adae1fc045512364d6517f47916c553e757226e5b9012d2170d
1616
codeSamplesNamespace: open-router-chat-completions-api-python-code-samples
17-
codeSamplesRevisionDigest: sha256:fb054934c4d0de58a48ca8cdfde7b4210f71c425fb9dfad02e8824b8a1848774
17+
codeSamplesRevisionDigest: sha256:fd8ed35536e452d20ff16d6c33d311ebd405bf7e0f9188cfafcba4cd81539d96
1818
workflow:
1919
workflowVersion: 1.0.0
2020
speakeasyVersion: latest

README.md

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -401,9 +401,15 @@ with OpenRouter(
401401
<!-- Start Server Selection [server] -->
402402
## Server Selection
403403

404-
### Server Variables
404+
### Select Server by Name
405405

406-
The default server `https://{provider_url}/api/v1` contains variables and is set to `https://openrouter.ai/api/v1` by default. To override default values, the following parameters are available when initializing the SDK client instance:
406+
You can override the default server globally by passing a server name to the `server: str` optional parameter when initializing the SDK client instance. The selected server will then be used as the default on the operations that use it. This table lists the names associated with the available servers:
407+
408+
| Name | Server | Variables | Description |
409+
| ------------ | ------------------------------- | -------------- | ----------------- |
410+
| `production` | `https://{provider_url}/api/v1` | `provider_url` | Production server |
411+
412+
If the selected server has variables, you may override its default values through the additional parameters made available in the SDK constructor:
407413

408414
| Variable | Parameter | Default | Description |
409415
| -------------- | ------------------- | ----------------- | ----------- |
@@ -417,6 +423,7 @@ import os
417423

418424

419425
with OpenRouter(
426+
server="production",
420427
provider_url="https://ruddy-guacamole.info/"
421428
api_key=os.getenv("OPENROUTER_API_KEY", ""),
422429
) as open_router:
@@ -437,7 +444,7 @@ with OpenRouter(
437444

438445
### Override Server URL Per-Client
439446

440-
The default server can be overridden globally by passing a URL to the `server_url: str` optional parameter when initializing the SDK client instance. For example:
447+
The default server can also be overridden globally by passing a URL to the `server_url: str` optional parameter when initializing the SDK client instance. For example:
441448
```python
442449
from openrouter import OpenRouter
443450
import os

pyproject.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
[project]
22
name = "openrouter"
33
version = "0.1.0"
4-
description = "Python Client SDK Generated by Speakeasy."
4+
description = "The OpenRouter Python SDK."
55
authors = [{ name = "Speakeasy" },]
66
readme = "README.md"
77
requires-python = ">=3.9.2"

src/openrouter/_version.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,8 @@
55
__title__: str = "openrouter"
66
__version__: str = "0.1.0"
77
__openapi_doc_version__: str = "1.0.0"
8-
__gen_version__: str = "2.701.8"
9-
__user_agent__: str = "speakeasy-sdk/python 0.1.0 2.701.8 1.0.0 openrouter"
8+
__gen_version__: str = "2.702.0"
9+
__user_agent__: str = "speakeasy-sdk/python 0.1.0 2.702.0 1.0.0 openrouter"
1010

1111
try:
1212
if __package__ is not None:

src/openrouter/models/chatcompletionchoice.py

Lines changed: 11 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -12,14 +12,17 @@
1212
OptionalNullable,
1313
UNSET,
1414
UNSET_SENTINEL,
15+
UnrecognizedStr,
1516
)
17+
from openrouter.utils import validate_open_enum
1618
from pydantic import model_serializer
17-
from typing import Literal
18-
from typing_extensions import NotRequired, TypedDict
19+
from pydantic.functional_validators import PlainValidator
20+
from typing import Literal, Union
21+
from typing_extensions import Annotated, NotRequired, TypedDict
1922

2023

21-
ChatCompletionChoiceFinishReason = Literal[
22-
"tool_calls", "stop", "length", "content_filter", "error"
24+
ChatCompletionChoiceFinishReason = Union[
25+
Literal["tool_calls", "stop", "length", "content_filter", "error"], UnrecognizedStr
2326
]
2427
r"""Reason the completion finished"""
2528

@@ -40,7 +43,10 @@ class ChatCompletionChoiceTypedDict(TypedDict):
4043
class ChatCompletionChoice(BaseModel):
4144
r"""Chat completion choice"""
4245

43-
finish_reason: Nullable[ChatCompletionChoiceFinishReason]
46+
finish_reason: Annotated[
47+
Nullable[ChatCompletionChoiceFinishReason],
48+
PlainValidator(validate_open_enum(False)),
49+
]
4450
r"""Reason the completion finished"""
4551

4652
index: float

src/openrouter/models/chatcompletionchunkchoice.py

Lines changed: 11 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -15,14 +15,17 @@
1515
OptionalNullable,
1616
UNSET,
1717
UNSET_SENTINEL,
18+
UnrecognizedStr,
1819
)
20+
from openrouter.utils import validate_open_enum
1921
from pydantic import model_serializer
20-
from typing import Literal
21-
from typing_extensions import NotRequired, TypedDict
22+
from pydantic.functional_validators import PlainValidator
23+
from typing import Literal, Union
24+
from typing_extensions import Annotated, NotRequired, TypedDict
2225

2326

24-
ChatCompletionChunkChoiceFinishReason = Literal[
25-
"tool_calls", "stop", "length", "content_filter", "error"
27+
ChatCompletionChunkChoiceFinishReason = Union[
28+
Literal["tool_calls", "stop", "length", "content_filter", "error"], UnrecognizedStr
2629
]
2730

2831

@@ -43,7 +46,10 @@ class ChatCompletionChunkChoice(BaseModel):
4346
delta: ChatCompletionChunkChoiceDelta
4447
r"""Delta changes in streaming response"""
4548

46-
finish_reason: Nullable[ChatCompletionChunkChoiceFinishReason]
49+
finish_reason: Annotated[
50+
Nullable[ChatCompletionChunkChoiceFinishReason],
51+
PlainValidator(validate_open_enum(False)),
52+
]
4753

4854
index: float
4955

0 commit comments

Comments
 (0)