openrouter 0.0.17__py3-none-any.whl → 0.0.19__py3-none-any.whl
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- openrouter/_version.py +3 -3
- openrouter/analytics.py +0 -2
- openrouter/api_keys.py +4 -24
- openrouter/basesdk.py +0 -6
- openrouter/chat.py +14 -154
- openrouter/completions.py +0 -2
- openrouter/components/__init__.py +75 -276
- openrouter/components/chatgenerationparams.py +17 -389
- openrouter/components/chatmessagecontentitem.py +1 -1
- openrouter/components/chatmessagecontentitemaudio.py +25 -6
- openrouter/components/chatmessagecontentitemtext.py +2 -9
- openrouter/components/chatmessagecontentitemvideo.py +5 -9
- openrouter/components/chatresponsechoice.py +67 -6
- openrouter/components/chatstreamingmessagechunk.py +1 -12
- openrouter/components/chatstreamingresponsechunk.py +1 -1
- openrouter/components/completionchoice.py +5 -18
- openrouter/components/completioncreateparams.py +10 -10
- openrouter/components/completionresponse.py +0 -3
- openrouter/components/message.py +9 -10
- openrouter/components/openairesponsesannotation.py +4 -11
- openrouter/components/openairesponsesreasoningeffort.py +0 -1
- openrouter/components/openresponsesnonstreamingresponse.py +10 -13
- openrouter/components/openresponsesrequest.py +120 -194
- openrouter/components/openresponsesstreamevent.py +39 -110
- openrouter/components/outputmessage.py +4 -10
- openrouter/components/parameter.py +0 -1
- openrouter/components/providername.py +1 -8
- openrouter/components/providersort.py +1 -0
- openrouter/components/publicendpoint.py +49 -49
- openrouter/components/publicpricing.py +49 -49
- openrouter/components/responseformattextconfig.py +7 -9
- openrouter/components/responsesoutputitem.py +10 -12
- openrouter/components/responsesoutputmessage.py +5 -10
- openrouter/credits.py +0 -4
- openrouter/embeddings.py +8 -10
- openrouter/endpoints.py +0 -4
- openrouter/generations.py +0 -2
- openrouter/models_.py +0 -6
- openrouter/oauth.py +0 -4
- openrouter/operations/__init__.py +34 -10
- openrouter/operations/createembeddings.py +247 -16
- openrouter/operations/getcredits.py +0 -19
- openrouter/operations/getparameters.py +71 -5
- openrouter/operations/updatekeys.py +2 -2
- openrouter/parameters.py +2 -4
- openrouter/providers.py +0 -2
- openrouter/responses.py +36 -74
- openrouter/sdk.py +0 -13
- openrouter/sdkconfiguration.py +0 -2
- openrouter/utils/forms.py +10 -21
- openrouter/utils/queryparams.py +2 -14
- openrouter/utils/retries.py +5 -69
- {openrouter-0.0.17.dist-info → openrouter-0.0.19.dist-info}/METADATA +1 -1
- {openrouter-0.0.17.dist-info → openrouter-0.0.19.dist-info}/RECORD +57 -71
- openrouter/components/_schema0.py +0 -93
- openrouter/components/_schema3.py +0 -228
- openrouter/components/chatcompletionfinishreason.py +0 -17
- openrouter/components/chatmessagecontentitemcachecontrol.py +0 -32
- openrouter/components/chatstreamingchoice.py +0 -72
- openrouter/components/pdfparserengine.py +0 -16
- openrouter/components/pdfparseroptions.py +0 -25
- openrouter/components/providerpreferences.py +0 -375
- openrouter/components/providersortconfig.py +0 -71
- openrouter/components/providersortunion.py +0 -23
- openrouter/components/websearchengine.py +0 -15
- openrouter/models/__init__.py +0 -3
- openrouter/models/internal/__init__.py +0 -54
- openrouter/models/internal/globals.py +0 -41
- {openrouter-0.0.17.dist-info → openrouter-0.0.19.dist-info}/WHEEL +0 -0
- {openrouter-0.0.17.dist-info → openrouter-0.0.19.dist-info}/licenses/LICENSE +0 -0
- {openrouter-0.0.17.dist-info → openrouter-0.0.19.dist-info}/top_level.txt +0 -0
|
@@ -1,32 +1,46 @@
|
|
|
1
1
|
"""Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT."""
|
|
2
2
|
|
|
3
3
|
from __future__ import annotations
|
|
4
|
-
from ._schema3 import Schema3, Schema3TypedDict
|
|
5
4
|
from .assistantmessage import AssistantMessage, AssistantMessageTypedDict
|
|
6
|
-
from .chatcompletionfinishreason import ChatCompletionFinishReason
|
|
7
5
|
from .chatmessagetokenlogprobs import (
|
|
8
6
|
ChatMessageTokenLogprobs,
|
|
9
7
|
ChatMessageTokenLogprobsTypedDict,
|
|
10
8
|
)
|
|
9
|
+
from .chatstreamingmessagechunk import (
|
|
10
|
+
ChatStreamingMessageChunk,
|
|
11
|
+
ChatStreamingMessageChunkTypedDict,
|
|
12
|
+
)
|
|
11
13
|
from openrouter.types import (
|
|
12
14
|
BaseModel,
|
|
13
15
|
Nullable,
|
|
14
16
|
OptionalNullable,
|
|
15
17
|
UNSET,
|
|
16
18
|
UNSET_SENTINEL,
|
|
19
|
+
UnrecognizedStr,
|
|
17
20
|
)
|
|
18
21
|
from openrouter.utils import validate_open_enum
|
|
19
22
|
from pydantic import model_serializer
|
|
20
23
|
from pydantic.functional_validators import PlainValidator
|
|
21
|
-
from typing import
|
|
24
|
+
from typing import Literal, Union
|
|
22
25
|
from typing_extensions import Annotated, NotRequired, TypedDict
|
|
23
26
|
|
|
24
27
|
|
|
28
|
+
ChatCompletionFinishReason = Union[
|
|
29
|
+
Literal[
|
|
30
|
+
"tool_calls",
|
|
31
|
+
"stop",
|
|
32
|
+
"length",
|
|
33
|
+
"content_filter",
|
|
34
|
+
"error",
|
|
35
|
+
],
|
|
36
|
+
UnrecognizedStr,
|
|
37
|
+
]
|
|
38
|
+
|
|
39
|
+
|
|
25
40
|
class ChatResponseChoiceTypedDict(TypedDict):
|
|
26
41
|
finish_reason: Nullable[ChatCompletionFinishReason]
|
|
27
42
|
index: float
|
|
28
43
|
message: AssistantMessageTypedDict
|
|
29
|
-
reasoning_details: NotRequired[List[Schema3TypedDict]]
|
|
30
44
|
logprobs: NotRequired[Nullable[ChatMessageTokenLogprobsTypedDict]]
|
|
31
45
|
|
|
32
46
|
|
|
@@ -39,13 +53,60 @@ class ChatResponseChoice(BaseModel):
|
|
|
39
53
|
|
|
40
54
|
message: AssistantMessage
|
|
41
55
|
|
|
42
|
-
|
|
56
|
+
logprobs: OptionalNullable[ChatMessageTokenLogprobs] = UNSET
|
|
57
|
+
|
|
58
|
+
@model_serializer(mode="wrap")
|
|
59
|
+
def serialize_model(self, handler):
|
|
60
|
+
optional_fields = ["logprobs"]
|
|
61
|
+
nullable_fields = ["finish_reason", "logprobs"]
|
|
62
|
+
null_default_fields = []
|
|
63
|
+
|
|
64
|
+
serialized = handler(self)
|
|
65
|
+
|
|
66
|
+
m = {}
|
|
67
|
+
|
|
68
|
+
for n, f in type(self).model_fields.items():
|
|
69
|
+
k = f.alias or n
|
|
70
|
+
val = serialized.get(k)
|
|
71
|
+
serialized.pop(k, None)
|
|
72
|
+
|
|
73
|
+
optional_nullable = k in optional_fields and k in nullable_fields
|
|
74
|
+
is_set = (
|
|
75
|
+
self.__pydantic_fields_set__.intersection({n})
|
|
76
|
+
or k in null_default_fields
|
|
77
|
+
) # pylint: disable=no-member
|
|
78
|
+
|
|
79
|
+
if val is not None and val != UNSET_SENTINEL:
|
|
80
|
+
m[k] = val
|
|
81
|
+
elif val != UNSET_SENTINEL and (
|
|
82
|
+
not k in optional_fields or (optional_nullable and is_set)
|
|
83
|
+
):
|
|
84
|
+
m[k] = val
|
|
85
|
+
|
|
86
|
+
return m
|
|
87
|
+
|
|
88
|
+
|
|
89
|
+
class ChatStreamingChoiceTypedDict(TypedDict):
|
|
90
|
+
delta: ChatStreamingMessageChunkTypedDict
|
|
91
|
+
finish_reason: Nullable[ChatCompletionFinishReason]
|
|
92
|
+
index: float
|
|
93
|
+
logprobs: NotRequired[Nullable[ChatMessageTokenLogprobsTypedDict]]
|
|
94
|
+
|
|
95
|
+
|
|
96
|
+
class ChatStreamingChoice(BaseModel):
|
|
97
|
+
delta: ChatStreamingMessageChunk
|
|
98
|
+
|
|
99
|
+
finish_reason: Annotated[
|
|
100
|
+
Nullable[ChatCompletionFinishReason], PlainValidator(validate_open_enum(False))
|
|
101
|
+
]
|
|
102
|
+
|
|
103
|
+
index: float
|
|
43
104
|
|
|
44
105
|
logprobs: OptionalNullable[ChatMessageTokenLogprobs] = UNSET
|
|
45
106
|
|
|
46
107
|
@model_serializer(mode="wrap")
|
|
47
108
|
def serialize_model(self, handler):
|
|
48
|
-
optional_fields = ["
|
|
109
|
+
optional_fields = ["logprobs"]
|
|
49
110
|
nullable_fields = ["finish_reason", "logprobs"]
|
|
50
111
|
null_default_fields = []
|
|
51
112
|
|
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
"""Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT."""
|
|
2
2
|
|
|
3
3
|
from __future__ import annotations
|
|
4
|
-
from ._schema3 import Schema3, Schema3TypedDict
|
|
5
4
|
from .chatstreamingmessagetoolcall import (
|
|
6
5
|
ChatStreamingMessageToolCall,
|
|
7
6
|
ChatStreamingMessageToolCallTypedDict,
|
|
@@ -27,7 +26,6 @@ class ChatStreamingMessageChunkTypedDict(TypedDict):
|
|
|
27
26
|
reasoning: NotRequired[Nullable[str]]
|
|
28
27
|
refusal: NotRequired[Nullable[str]]
|
|
29
28
|
tool_calls: NotRequired[List[ChatStreamingMessageToolCallTypedDict]]
|
|
30
|
-
reasoning_details: NotRequired[List[Schema3TypedDict]]
|
|
31
29
|
|
|
32
30
|
|
|
33
31
|
class ChatStreamingMessageChunk(BaseModel):
|
|
@@ -41,18 +39,9 @@ class ChatStreamingMessageChunk(BaseModel):
|
|
|
41
39
|
|
|
42
40
|
tool_calls: Optional[List[ChatStreamingMessageToolCall]] = None
|
|
43
41
|
|
|
44
|
-
reasoning_details: Optional[List[Schema3]] = None
|
|
45
|
-
|
|
46
42
|
@model_serializer(mode="wrap")
|
|
47
43
|
def serialize_model(self, handler):
|
|
48
|
-
optional_fields = [
|
|
49
|
-
"role",
|
|
50
|
-
"content",
|
|
51
|
-
"reasoning",
|
|
52
|
-
"refusal",
|
|
53
|
-
"tool_calls",
|
|
54
|
-
"reasoning_details",
|
|
55
|
-
]
|
|
44
|
+
optional_fields = ["role", "content", "reasoning", "refusal", "tool_calls"]
|
|
56
45
|
nullable_fields = ["content", "reasoning", "refusal"]
|
|
57
46
|
null_default_fields = []
|
|
58
47
|
|
|
@@ -5,7 +5,7 @@ from .chatgenerationtokenusage import (
|
|
|
5
5
|
ChatGenerationTokenUsage,
|
|
6
6
|
ChatGenerationTokenUsageTypedDict,
|
|
7
7
|
)
|
|
8
|
-
from .
|
|
8
|
+
from .chatresponsechoice import ChatStreamingChoice, ChatStreamingChoiceTypedDict
|
|
9
9
|
from openrouter.types import (
|
|
10
10
|
BaseModel,
|
|
11
11
|
Nullable,
|
|
@@ -2,19 +2,12 @@
|
|
|
2
2
|
|
|
3
3
|
from __future__ import annotations
|
|
4
4
|
from .completionlogprobs import CompletionLogprobs, CompletionLogprobsTypedDict
|
|
5
|
-
from openrouter.types import
|
|
6
|
-
BaseModel,
|
|
7
|
-
Nullable,
|
|
8
|
-
OptionalNullable,
|
|
9
|
-
UNSET,
|
|
10
|
-
UNSET_SENTINEL,
|
|
11
|
-
UnrecognizedStr,
|
|
12
|
-
)
|
|
5
|
+
from openrouter.types import BaseModel, Nullable, UNSET_SENTINEL, UnrecognizedStr
|
|
13
6
|
from openrouter.utils import validate_open_enum
|
|
14
7
|
from pydantic import model_serializer
|
|
15
8
|
from pydantic.functional_validators import PlainValidator
|
|
16
|
-
from typing import Literal,
|
|
17
|
-
from typing_extensions import Annotated,
|
|
9
|
+
from typing import Literal, Union
|
|
10
|
+
from typing_extensions import Annotated, TypedDict
|
|
18
11
|
|
|
19
12
|
|
|
20
13
|
CompletionFinishReason = Union[
|
|
@@ -32,8 +25,6 @@ class CompletionChoiceTypedDict(TypedDict):
|
|
|
32
25
|
index: float
|
|
33
26
|
logprobs: Nullable[CompletionLogprobsTypedDict]
|
|
34
27
|
finish_reason: Nullable[CompletionFinishReason]
|
|
35
|
-
native_finish_reason: NotRequired[str]
|
|
36
|
-
reasoning: NotRequired[Nullable[str]]
|
|
37
28
|
|
|
38
29
|
|
|
39
30
|
class CompletionChoice(BaseModel):
|
|
@@ -47,14 +38,10 @@ class CompletionChoice(BaseModel):
|
|
|
47
38
|
Nullable[CompletionFinishReason], PlainValidator(validate_open_enum(False))
|
|
48
39
|
]
|
|
49
40
|
|
|
50
|
-
native_finish_reason: Optional[str] = None
|
|
51
|
-
|
|
52
|
-
reasoning: OptionalNullable[str] = UNSET
|
|
53
|
-
|
|
54
41
|
@model_serializer(mode="wrap")
|
|
55
42
|
def serialize_model(self, handler):
|
|
56
|
-
optional_fields = [
|
|
57
|
-
nullable_fields = ["logprobs", "finish_reason"
|
|
43
|
+
optional_fields = []
|
|
44
|
+
nullable_fields = ["logprobs", "finish_reason"]
|
|
58
45
|
null_default_fields = []
|
|
59
46
|
|
|
60
47
|
serialized = handler(self)
|
|
@@ -16,9 +16,9 @@ from openrouter.types import (
|
|
|
16
16
|
UNSET,
|
|
17
17
|
UNSET_SENTINEL,
|
|
18
18
|
)
|
|
19
|
-
from openrouter.utils import
|
|
19
|
+
from openrouter.utils import validate_const
|
|
20
20
|
import pydantic
|
|
21
|
-
from pydantic import
|
|
21
|
+
from pydantic import model_serializer
|
|
22
22
|
from pydantic.functional_validators import AfterValidator
|
|
23
23
|
from typing import Dict, List, Literal, Optional, Union
|
|
24
24
|
from typing_extensions import Annotated, NotRequired, TypeAliasType, TypedDict
|
|
@@ -127,16 +127,16 @@ CompletionCreateParamsResponseFormatUnionTypedDict = TypeAliasType(
|
|
|
127
127
|
)
|
|
128
128
|
|
|
129
129
|
|
|
130
|
-
CompletionCreateParamsResponseFormatUnion =
|
|
130
|
+
CompletionCreateParamsResponseFormatUnion = TypeAliasType(
|
|
131
|
+
"CompletionCreateParamsResponseFormatUnion",
|
|
131
132
|
Union[
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
133
|
+
CompletionCreateParamsResponseFormatText,
|
|
134
|
+
CompletionCreateParamsResponseFormatJSONObject,
|
|
135
|
+
CompletionCreateParamsResponseFormatPython,
|
|
136
|
+
ResponseFormatJSONSchema,
|
|
137
|
+
ResponseFormatTextGrammar,
|
|
137
138
|
],
|
|
138
|
-
|
|
139
|
-
]
|
|
139
|
+
)
|
|
140
140
|
|
|
141
141
|
|
|
142
142
|
class CompletionCreateParamsTypedDict(TypedDict):
|
|
@@ -17,7 +17,6 @@ class CompletionResponseTypedDict(TypedDict):
|
|
|
17
17
|
model: str
|
|
18
18
|
choices: List[CompletionChoiceTypedDict]
|
|
19
19
|
object: Literal["text_completion"]
|
|
20
|
-
provider: NotRequired[str]
|
|
21
20
|
system_fingerprint: NotRequired[str]
|
|
22
21
|
usage: NotRequired[CompletionUsageTypedDict]
|
|
23
22
|
|
|
@@ -39,8 +38,6 @@ class CompletionResponse(BaseModel):
|
|
|
39
38
|
pydantic.Field(alias="object"),
|
|
40
39
|
] = "text_completion"
|
|
41
40
|
|
|
42
|
-
provider: Optional[str] = None
|
|
43
|
-
|
|
44
41
|
system_fingerprint: Optional[str] = None
|
|
45
42
|
|
|
46
43
|
usage: Optional[CompletionUsage] = None
|
openrouter/components/message.py
CHANGED
|
@@ -10,9 +10,8 @@ from .systemmessage import SystemMessage, SystemMessageTypedDict
|
|
|
10
10
|
from .toolresponsemessage import ToolResponseMessage, ToolResponseMessageTypedDict
|
|
11
11
|
from .usermessage import UserMessage, UserMessageTypedDict
|
|
12
12
|
from openrouter.types import BaseModel
|
|
13
|
-
from openrouter.utils import
|
|
13
|
+
from openrouter.utils import validate_const
|
|
14
14
|
import pydantic
|
|
15
|
-
from pydantic import Discriminator, Tag
|
|
16
15
|
from pydantic.functional_validators import AfterValidator
|
|
17
16
|
from typing import List, Literal, Optional, Union
|
|
18
17
|
from typing_extensions import Annotated, NotRequired, TypeAliasType, TypedDict
|
|
@@ -57,13 +56,13 @@ MessageTypedDict = TypeAliasType(
|
|
|
57
56
|
)
|
|
58
57
|
|
|
59
58
|
|
|
60
|
-
Message =
|
|
59
|
+
Message = TypeAliasType(
|
|
60
|
+
"Message",
|
|
61
61
|
Union[
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
62
|
+
SystemMessage,
|
|
63
|
+
UserMessage,
|
|
64
|
+
MessageDeveloper,
|
|
65
|
+
ToolResponseMessage,
|
|
66
|
+
AssistantMessage,
|
|
67
67
|
],
|
|
68
|
-
|
|
69
|
-
]
|
|
68
|
+
)
|
|
@@ -4,10 +4,8 @@ from __future__ import annotations
|
|
|
4
4
|
from .filecitation import FileCitation, FileCitationTypedDict
|
|
5
5
|
from .filepath import FilePath, FilePathTypedDict
|
|
6
6
|
from .urlcitation import URLCitation, URLCitationTypedDict
|
|
7
|
-
from openrouter.utils import get_discriminator
|
|
8
|
-
from pydantic import Discriminator, Tag
|
|
9
7
|
from typing import Union
|
|
10
|
-
from typing_extensions import
|
|
8
|
+
from typing_extensions import TypeAliasType
|
|
11
9
|
|
|
12
10
|
|
|
13
11
|
OpenAIResponsesAnnotationTypedDict = TypeAliasType(
|
|
@@ -16,11 +14,6 @@ OpenAIResponsesAnnotationTypedDict = TypeAliasType(
|
|
|
16
14
|
)
|
|
17
15
|
|
|
18
16
|
|
|
19
|
-
OpenAIResponsesAnnotation =
|
|
20
|
-
Union[
|
|
21
|
-
|
|
22
|
-
Annotated[URLCitation, Tag("url_citation")],
|
|
23
|
-
Annotated[FilePath, Tag("file_path")],
|
|
24
|
-
],
|
|
25
|
-
Discriminator(lambda m: get_discriminator(m, "type", "type")),
|
|
26
|
-
]
|
|
17
|
+
OpenAIResponsesAnnotation = TypeAliasType(
|
|
18
|
+
"OpenAIResponsesAnnotation", Union[FilePath, FileCitation, URLCitation]
|
|
19
|
+
)
|
|
@@ -48,8 +48,8 @@ from openrouter.types import (
|
|
|
48
48
|
UNSET,
|
|
49
49
|
UNSET_SENTINEL,
|
|
50
50
|
)
|
|
51
|
-
from openrouter.utils import
|
|
52
|
-
from pydantic import
|
|
51
|
+
from openrouter.utils import validate_open_enum
|
|
52
|
+
from pydantic import model_serializer
|
|
53
53
|
from pydantic.functional_validators import PlainValidator
|
|
54
54
|
from typing import Any, Dict, List, Literal, Optional, Union
|
|
55
55
|
from typing_extensions import Annotated, NotRequired, TypeAliasType, TypedDict
|
|
@@ -127,19 +127,16 @@ OpenResponsesNonStreamingResponseToolUnionTypedDict = TypeAliasType(
|
|
|
127
127
|
)
|
|
128
128
|
|
|
129
129
|
|
|
130
|
-
OpenResponsesNonStreamingResponseToolUnion =
|
|
130
|
+
OpenResponsesNonStreamingResponseToolUnion = TypeAliasType(
|
|
131
|
+
"OpenResponsesNonStreamingResponseToolUnion",
|
|
131
132
|
Union[
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
],
|
|
138
|
-
Annotated[OpenResponsesWebSearchTool, Tag("web_search")],
|
|
139
|
-
Annotated[OpenResponsesWebSearch20250826Tool, Tag("web_search_2025_08_26")],
|
|
133
|
+
OpenResponsesWebSearchPreviewTool,
|
|
134
|
+
OpenResponsesWebSearchPreview20250311Tool,
|
|
135
|
+
OpenResponsesWebSearchTool,
|
|
136
|
+
OpenResponsesWebSearch20250826Tool,
|
|
137
|
+
OpenResponsesNonStreamingResponseToolFunction,
|
|
140
138
|
],
|
|
141
|
-
|
|
142
|
-
]
|
|
139
|
+
)
|
|
143
140
|
|
|
144
141
|
|
|
145
142
|
class OpenResponsesNonStreamingResponseTypedDict(TypedDict):
|