openrouter 0.0.16__py3-none-any.whl → 0.0.17__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 +2 -0
- openrouter/api_keys.py +24 -4
- openrouter/basesdk.py +6 -0
- openrouter/chat.py +154 -14
- openrouter/completions.py +2 -0
- openrouter/components/__init__.py +299 -76
- openrouter/components/_schema0.py +93 -0
- openrouter/components/_schema3.py +228 -0
- openrouter/components/chatgenerationparams.py +389 -16
- openrouter/components/chatmessagecontentitem.py +2 -1
- openrouter/components/chatmessagecontentitemaudio.py +6 -25
- openrouter/components/chatmessagecontentitemcachecontrol.py +32 -0
- openrouter/components/chatmessagecontentitemtext.py +9 -2
- openrouter/components/chatmessagecontentitemvideo.py +50 -9
- openrouter/components/chatresponsechoice.py +6 -1
- openrouter/components/chatstreamingmessagechunk.py +12 -1
- openrouter/components/completionchoice.py +18 -5
- openrouter/components/completioncreateparams.py +10 -10
- openrouter/components/completionresponse.py +3 -0
- openrouter/components/datacollection.py +19 -0
- openrouter/components/message.py +10 -9
- openrouter/components/openairesponsesannotation.py +11 -4
- openrouter/components/openairesponsesreasoningeffort.py +2 -0
- openrouter/components/openresponsesnonstreamingresponse.py +13 -10
- openrouter/components/openresponsesreasoning.py +1 -0
- openrouter/components/openresponsesrequest.py +194 -143
- openrouter/components/openresponsesstreamevent.py +110 -39
- openrouter/components/outputmessage.py +10 -4
- openrouter/components/parameter.py +1 -0
- openrouter/components/pdfparserengine.py +16 -0
- openrouter/components/pdfparseroptions.py +25 -0
- openrouter/components/providername.py +9 -26
- openrouter/components/providerpreferences.py +375 -0
- openrouter/components/providersort.py +15 -0
- openrouter/components/providersortconfig.py +71 -0
- openrouter/components/providersortunion.py +23 -0
- openrouter/components/publicendpoint.py +50 -45
- openrouter/components/publicpricing.py +50 -45
- openrouter/components/responseformattextconfig.py +9 -7
- openrouter/components/responsesoutputitem.py +12 -10
- openrouter/components/responsesoutputmessage.py +10 -5
- openrouter/components/websearchengine.py +15 -0
- openrouter/credits.py +4 -0
- openrouter/embeddings.py +34 -24
- openrouter/endpoints.py +4 -0
- openrouter/generations.py +2 -0
- openrouter/models/__init__.py +3 -0
- openrouter/models/internal/__init__.py +54 -0
- openrouter/models/internal/globals.py +41 -0
- openrouter/models_.py +6 -0
- openrouter/oauth.py +4 -0
- openrouter/operations/__init__.py +46 -49
- openrouter/operations/createembeddings.py +68 -264
- openrouter/operations/getcredits.py +19 -0
- openrouter/operations/getparameters.py +5 -77
- openrouter/operations/updatekeys.py +2 -2
- openrouter/parameters.py +4 -2
- openrouter/providers.py +2 -0
- openrouter/responses.py +74 -36
- openrouter/sdk.py +13 -0
- openrouter/sdkconfiguration.py +2 -0
- openrouter/utils/forms.py +21 -10
- openrouter/utils/queryparams.py +14 -2
- openrouter/utils/retries.py +69 -5
- {openrouter-0.0.16.dist-info → openrouter-0.0.17.dist-info}/METADATA +2 -1
- {openrouter-0.0.16.dist-info → openrouter-0.0.17.dist-info}/RECORD +70 -56
- {openrouter-0.0.16.dist-info → openrouter-0.0.17.dist-info}/WHEEL +0 -0
- {openrouter-0.0.16.dist-info → openrouter-0.0.17.dist-info}/licenses/LICENSE +0 -0
- {openrouter-0.0.16.dist-info → openrouter-0.0.17.dist-info}/top_level.txt +0 -0
|
@@ -1,6 +1,7 @@
|
|
|
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
|
|
4
5
|
from .assistantmessage import AssistantMessage, AssistantMessageTypedDict
|
|
5
6
|
from .chatcompletionfinishreason import ChatCompletionFinishReason
|
|
6
7
|
from .chatmessagetokenlogprobs import (
|
|
@@ -17,6 +18,7 @@ from openrouter.types import (
|
|
|
17
18
|
from openrouter.utils import validate_open_enum
|
|
18
19
|
from pydantic import model_serializer
|
|
19
20
|
from pydantic.functional_validators import PlainValidator
|
|
21
|
+
from typing import List, Optional
|
|
20
22
|
from typing_extensions import Annotated, NotRequired, TypedDict
|
|
21
23
|
|
|
22
24
|
|
|
@@ -24,6 +26,7 @@ class ChatResponseChoiceTypedDict(TypedDict):
|
|
|
24
26
|
finish_reason: Nullable[ChatCompletionFinishReason]
|
|
25
27
|
index: float
|
|
26
28
|
message: AssistantMessageTypedDict
|
|
29
|
+
reasoning_details: NotRequired[List[Schema3TypedDict]]
|
|
27
30
|
logprobs: NotRequired[Nullable[ChatMessageTokenLogprobsTypedDict]]
|
|
28
31
|
|
|
29
32
|
|
|
@@ -36,11 +39,13 @@ class ChatResponseChoice(BaseModel):
|
|
|
36
39
|
|
|
37
40
|
message: AssistantMessage
|
|
38
41
|
|
|
42
|
+
reasoning_details: Optional[List[Schema3]] = None
|
|
43
|
+
|
|
39
44
|
logprobs: OptionalNullable[ChatMessageTokenLogprobs] = UNSET
|
|
40
45
|
|
|
41
46
|
@model_serializer(mode="wrap")
|
|
42
47
|
def serialize_model(self, handler):
|
|
43
|
-
optional_fields = ["logprobs"]
|
|
48
|
+
optional_fields = ["reasoning_details", "logprobs"]
|
|
44
49
|
nullable_fields = ["finish_reason", "logprobs"]
|
|
45
50
|
null_default_fields = []
|
|
46
51
|
|
|
@@ -1,6 +1,7 @@
|
|
|
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
|
|
4
5
|
from .chatstreamingmessagetoolcall import (
|
|
5
6
|
ChatStreamingMessageToolCall,
|
|
6
7
|
ChatStreamingMessageToolCallTypedDict,
|
|
@@ -26,6 +27,7 @@ class ChatStreamingMessageChunkTypedDict(TypedDict):
|
|
|
26
27
|
reasoning: NotRequired[Nullable[str]]
|
|
27
28
|
refusal: NotRequired[Nullable[str]]
|
|
28
29
|
tool_calls: NotRequired[List[ChatStreamingMessageToolCallTypedDict]]
|
|
30
|
+
reasoning_details: NotRequired[List[Schema3TypedDict]]
|
|
29
31
|
|
|
30
32
|
|
|
31
33
|
class ChatStreamingMessageChunk(BaseModel):
|
|
@@ -39,9 +41,18 @@ class ChatStreamingMessageChunk(BaseModel):
|
|
|
39
41
|
|
|
40
42
|
tool_calls: Optional[List[ChatStreamingMessageToolCall]] = None
|
|
41
43
|
|
|
44
|
+
reasoning_details: Optional[List[Schema3]] = None
|
|
45
|
+
|
|
42
46
|
@model_serializer(mode="wrap")
|
|
43
47
|
def serialize_model(self, handler):
|
|
44
|
-
optional_fields = [
|
|
48
|
+
optional_fields = [
|
|
49
|
+
"role",
|
|
50
|
+
"content",
|
|
51
|
+
"reasoning",
|
|
52
|
+
"refusal",
|
|
53
|
+
"tool_calls",
|
|
54
|
+
"reasoning_details",
|
|
55
|
+
]
|
|
45
56
|
nullable_fields = ["content", "reasoning", "refusal"]
|
|
46
57
|
null_default_fields = []
|
|
47
58
|
|
|
@@ -2,12 +2,19 @@
|
|
|
2
2
|
|
|
3
3
|
from __future__ import annotations
|
|
4
4
|
from .completionlogprobs import CompletionLogprobs, CompletionLogprobsTypedDict
|
|
5
|
-
from openrouter.types import
|
|
5
|
+
from openrouter.types import (
|
|
6
|
+
BaseModel,
|
|
7
|
+
Nullable,
|
|
8
|
+
OptionalNullable,
|
|
9
|
+
UNSET,
|
|
10
|
+
UNSET_SENTINEL,
|
|
11
|
+
UnrecognizedStr,
|
|
12
|
+
)
|
|
6
13
|
from openrouter.utils import validate_open_enum
|
|
7
14
|
from pydantic import model_serializer
|
|
8
15
|
from pydantic.functional_validators import PlainValidator
|
|
9
|
-
from typing import Literal, Union
|
|
10
|
-
from typing_extensions import Annotated, TypedDict
|
|
16
|
+
from typing import Literal, Optional, Union
|
|
17
|
+
from typing_extensions import Annotated, NotRequired, TypedDict
|
|
11
18
|
|
|
12
19
|
|
|
13
20
|
CompletionFinishReason = Union[
|
|
@@ -25,6 +32,8 @@ class CompletionChoiceTypedDict(TypedDict):
|
|
|
25
32
|
index: float
|
|
26
33
|
logprobs: Nullable[CompletionLogprobsTypedDict]
|
|
27
34
|
finish_reason: Nullable[CompletionFinishReason]
|
|
35
|
+
native_finish_reason: NotRequired[str]
|
|
36
|
+
reasoning: NotRequired[Nullable[str]]
|
|
28
37
|
|
|
29
38
|
|
|
30
39
|
class CompletionChoice(BaseModel):
|
|
@@ -38,10 +47,14 @@ class CompletionChoice(BaseModel):
|
|
|
38
47
|
Nullable[CompletionFinishReason], PlainValidator(validate_open_enum(False))
|
|
39
48
|
]
|
|
40
49
|
|
|
50
|
+
native_finish_reason: Optional[str] = None
|
|
51
|
+
|
|
52
|
+
reasoning: OptionalNullable[str] = UNSET
|
|
53
|
+
|
|
41
54
|
@model_serializer(mode="wrap")
|
|
42
55
|
def serialize_model(self, handler):
|
|
43
|
-
optional_fields = []
|
|
44
|
-
nullable_fields = ["logprobs", "finish_reason"]
|
|
56
|
+
optional_fields = ["native_finish_reason", "reasoning"]
|
|
57
|
+
nullable_fields = ["logprobs", "finish_reason", "reasoning"]
|
|
45
58
|
null_default_fields = []
|
|
46
59
|
|
|
47
60
|
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 validate_const
|
|
19
|
+
from openrouter.utils import get_discriminator, validate_const
|
|
20
20
|
import pydantic
|
|
21
|
-
from pydantic import model_serializer
|
|
21
|
+
from pydantic import Discriminator, Tag, 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 =
|
|
131
|
-
"CompletionCreateParamsResponseFormatUnion",
|
|
130
|
+
CompletionCreateParamsResponseFormatUnion = Annotated[
|
|
132
131
|
Union[
|
|
133
|
-
CompletionCreateParamsResponseFormatText,
|
|
134
|
-
CompletionCreateParamsResponseFormatJSONObject,
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
132
|
+
Annotated[CompletionCreateParamsResponseFormatText, Tag("text")],
|
|
133
|
+
Annotated[CompletionCreateParamsResponseFormatJSONObject, Tag("json_object")],
|
|
134
|
+
Annotated[ResponseFormatJSONSchema, Tag("json_schema")],
|
|
135
|
+
Annotated[ResponseFormatTextGrammar, Tag("grammar")],
|
|
136
|
+
Annotated[CompletionCreateParamsResponseFormatPython, Tag("python")],
|
|
138
137
|
],
|
|
139
|
-
)
|
|
138
|
+
Discriminator(lambda m: get_discriminator(m, "type", "type")),
|
|
139
|
+
]
|
|
140
140
|
|
|
141
141
|
|
|
142
142
|
class CompletionCreateParamsTypedDict(TypedDict):
|
|
@@ -17,6 +17,7 @@ class CompletionResponseTypedDict(TypedDict):
|
|
|
17
17
|
model: str
|
|
18
18
|
choices: List[CompletionChoiceTypedDict]
|
|
19
19
|
object: Literal["text_completion"]
|
|
20
|
+
provider: NotRequired[str]
|
|
20
21
|
system_fingerprint: NotRequired[str]
|
|
21
22
|
usage: NotRequired[CompletionUsageTypedDict]
|
|
22
23
|
|
|
@@ -38,6 +39,8 @@ class CompletionResponse(BaseModel):
|
|
|
38
39
|
pydantic.Field(alias="object"),
|
|
39
40
|
] = "text_completion"
|
|
40
41
|
|
|
42
|
+
provider: Optional[str] = None
|
|
43
|
+
|
|
41
44
|
system_fingerprint: Optional[str] = None
|
|
42
45
|
|
|
43
46
|
usage: Optional[CompletionUsage] = None
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
"""Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT."""
|
|
2
|
+
|
|
3
|
+
from __future__ import annotations
|
|
4
|
+
from openrouter.types import UnrecognizedStr
|
|
5
|
+
from typing import Literal, Union
|
|
6
|
+
|
|
7
|
+
|
|
8
|
+
DataCollection = Union[
|
|
9
|
+
Literal[
|
|
10
|
+
"deny",
|
|
11
|
+
"allow",
|
|
12
|
+
],
|
|
13
|
+
UnrecognizedStr,
|
|
14
|
+
]
|
|
15
|
+
r"""Data collection setting. If no available model provider meets the requirement, your request will return an error.
|
|
16
|
+
- allow: (default) allow providers which store user data non-transiently and may train on it
|
|
17
|
+
|
|
18
|
+
- deny: use only providers which do not collect user data.
|
|
19
|
+
"""
|
openrouter/components/message.py
CHANGED
|
@@ -10,8 +10,9 @@ 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 validate_const
|
|
13
|
+
from openrouter.utils import get_discriminator, validate_const
|
|
14
14
|
import pydantic
|
|
15
|
+
from pydantic import Discriminator, Tag
|
|
15
16
|
from pydantic.functional_validators import AfterValidator
|
|
16
17
|
from typing import List, Literal, Optional, Union
|
|
17
18
|
from typing_extensions import Annotated, NotRequired, TypeAliasType, TypedDict
|
|
@@ -56,13 +57,13 @@ MessageTypedDict = TypeAliasType(
|
|
|
56
57
|
)
|
|
57
58
|
|
|
58
59
|
|
|
59
|
-
Message =
|
|
60
|
-
"Message",
|
|
60
|
+
Message = Annotated[
|
|
61
61
|
Union[
|
|
62
|
-
SystemMessage,
|
|
63
|
-
UserMessage,
|
|
64
|
-
MessageDeveloper,
|
|
65
|
-
|
|
66
|
-
|
|
62
|
+
Annotated[SystemMessage, Tag("system")],
|
|
63
|
+
Annotated[UserMessage, Tag("user")],
|
|
64
|
+
Annotated[MessageDeveloper, Tag("developer")],
|
|
65
|
+
Annotated[AssistantMessage, Tag("assistant")],
|
|
66
|
+
Annotated[ToolResponseMessage, Tag("tool")],
|
|
67
67
|
],
|
|
68
|
-
)
|
|
68
|
+
Discriminator(lambda m: get_discriminator(m, "role", "role")),
|
|
69
|
+
]
|
|
@@ -4,8 +4,10 @@ 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
|
|
7
9
|
from typing import Union
|
|
8
|
-
from typing_extensions import TypeAliasType
|
|
10
|
+
from typing_extensions import Annotated, TypeAliasType
|
|
9
11
|
|
|
10
12
|
|
|
11
13
|
OpenAIResponsesAnnotationTypedDict = TypeAliasType(
|
|
@@ -14,6 +16,11 @@ OpenAIResponsesAnnotationTypedDict = TypeAliasType(
|
|
|
14
16
|
)
|
|
15
17
|
|
|
16
18
|
|
|
17
|
-
OpenAIResponsesAnnotation =
|
|
18
|
-
|
|
19
|
-
)
|
|
19
|
+
OpenAIResponsesAnnotation = Annotated[
|
|
20
|
+
Union[
|
|
21
|
+
Annotated[FileCitation, Tag("file_citation")],
|
|
22
|
+
Annotated[URLCitation, Tag("url_citation")],
|
|
23
|
+
Annotated[FilePath, Tag("file_path")],
|
|
24
|
+
],
|
|
25
|
+
Discriminator(lambda m: get_discriminator(m, "type", "type")),
|
|
26
|
+
]
|
|
@@ -48,8 +48,8 @@ from openrouter.types import (
|
|
|
48
48
|
UNSET,
|
|
49
49
|
UNSET_SENTINEL,
|
|
50
50
|
)
|
|
51
|
-
from openrouter.utils import validate_open_enum
|
|
52
|
-
from pydantic import model_serializer
|
|
51
|
+
from openrouter.utils import get_discriminator, validate_open_enum
|
|
52
|
+
from pydantic import Discriminator, Tag, 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,16 +127,19 @@ OpenResponsesNonStreamingResponseToolUnionTypedDict = TypeAliasType(
|
|
|
127
127
|
)
|
|
128
128
|
|
|
129
129
|
|
|
130
|
-
OpenResponsesNonStreamingResponseToolUnion =
|
|
131
|
-
"OpenResponsesNonStreamingResponseToolUnion",
|
|
130
|
+
OpenResponsesNonStreamingResponseToolUnion = Annotated[
|
|
132
131
|
Union[
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
132
|
+
Annotated[OpenResponsesNonStreamingResponseToolFunction, Tag("function")],
|
|
133
|
+
Annotated[OpenResponsesWebSearchPreviewTool, Tag("web_search_preview")],
|
|
134
|
+
Annotated[
|
|
135
|
+
OpenResponsesWebSearchPreview20250311Tool,
|
|
136
|
+
Tag("web_search_preview_2025_03_11"),
|
|
137
|
+
],
|
|
138
|
+
Annotated[OpenResponsesWebSearchTool, Tag("web_search")],
|
|
139
|
+
Annotated[OpenResponsesWebSearch20250826Tool, Tag("web_search_2025_08_26")],
|
|
138
140
|
],
|
|
139
|
-
)
|
|
141
|
+
Discriminator(lambda m: get_discriminator(m, "type", "type")),
|
|
142
|
+
]
|
|
140
143
|
|
|
141
144
|
|
|
142
145
|
class OpenResponsesNonStreamingResponseTypedDict(TypedDict):
|