mirror of
https://github.com/wassname/openrouter-python-sdk-retry-errors.git
synced 2026-08-02 12:50:48 +08:00
fix: examples, enums and regenerate (#2)
This commit is contained in:
@@ -3,10 +3,10 @@
|
||||
import importlib.metadata
|
||||
|
||||
__title__: str = "openrouter"
|
||||
__version__: str = "0.1.3"
|
||||
__version__: str = "0.5.2"
|
||||
__openapi_doc_version__: str = "1.0.0"
|
||||
__gen_version__: str = "2.687.1"
|
||||
__user_agent__: str = "speakeasy-sdk/python 0.1.3 2.687.1 1.0.0 openrouter"
|
||||
__gen_version__: str = "2.694.1"
|
||||
__user_agent__: str = "speakeasy-sdk/python 0.5.2 2.694.1 1.0.0 openrouter"
|
||||
|
||||
try:
|
||||
if __package__ is not None:
|
||||
|
||||
@@ -15,9 +15,19 @@ from urllib.parse import parse_qs, urlparse
|
||||
|
||||
class BaseSDK:
|
||||
sdk_configuration: SDKConfiguration
|
||||
parent_ref: Optional[object] = None
|
||||
"""
|
||||
Reference to the root SDK instance, if any. This will prevent it from
|
||||
being garbage collected while there are active streams.
|
||||
"""
|
||||
|
||||
def __init__(self, sdk_config: SDKConfiguration) -> None:
|
||||
def __init__(
|
||||
self,
|
||||
sdk_config: SDKConfiguration,
|
||||
parent_ref: Optional[object] = None,
|
||||
) -> None:
|
||||
self.sdk_configuration = sdk_config
|
||||
self.parent_ref = parent_ref
|
||||
|
||||
def _get_url(self, base_url, url_variables):
|
||||
sdk_url, sdk_variables = self.sdk_configuration.get_server_details()
|
||||
|
||||
+14
-12
@@ -69,7 +69,7 @@ class Chat(BaseSDK):
|
||||
] = None,
|
||||
top_p: OptionalNullable[float] = 1,
|
||||
user: Optional[str] = None,
|
||||
models_llm: OptionalNullable[List[str]] = UNSET,
|
||||
fallback_models: OptionalNullable[List[str]] = UNSET,
|
||||
reasoning_effort: OptionalNullable[
|
||||
models.ChatCompletionCreateParamsReasoningEffort
|
||||
] = UNSET,
|
||||
@@ -115,7 +115,7 @@ class Chat(BaseSDK):
|
||||
:param tools: Available tools for function calling
|
||||
:param top_p: Nucleus sampling parameter (0-1)
|
||||
:param user: Unique user identifier
|
||||
:param models_llm: Order of models to fallback to for this request
|
||||
:param fallback_models: Order of models to fallback to for this request
|
||||
:param reasoning_effort: Reasoning effort
|
||||
:param provider: When multiple model providers are available, optionally indicate your routing preference.
|
||||
:param plugins: Plugins you want to enable for this request, including their settings.
|
||||
@@ -170,7 +170,7 @@ class Chat(BaseSDK):
|
||||
),
|
||||
top_p=top_p,
|
||||
user=user,
|
||||
models_llm=models_llm,
|
||||
fallback_models=fallback_models,
|
||||
reasoning_effort=reasoning_effort,
|
||||
provider=utils.get_pydantic_model(
|
||||
provider, OptionalNullable[models.ChatCompletionCreateParamsProvider]
|
||||
@@ -305,7 +305,7 @@ class Chat(BaseSDK):
|
||||
] = None,
|
||||
top_p: OptionalNullable[float] = 1,
|
||||
user: Optional[str] = None,
|
||||
models_llm: OptionalNullable[List[str]] = UNSET,
|
||||
fallback_models: OptionalNullable[List[str]] = UNSET,
|
||||
reasoning_effort: OptionalNullable[
|
||||
models.ChatCompletionCreateParamsReasoningEffort
|
||||
] = UNSET,
|
||||
@@ -351,7 +351,7 @@ class Chat(BaseSDK):
|
||||
:param tools: Available tools for function calling
|
||||
:param top_p: Nucleus sampling parameter (0-1)
|
||||
:param user: Unique user identifier
|
||||
:param models_llm: Order of models to fallback to for this request
|
||||
:param fallback_models: Order of models to fallback to for this request
|
||||
:param reasoning_effort: Reasoning effort
|
||||
:param provider: When multiple model providers are available, optionally indicate your routing preference.
|
||||
:param plugins: Plugins you want to enable for this request, including their settings.
|
||||
@@ -406,7 +406,7 @@ class Chat(BaseSDK):
|
||||
),
|
||||
top_p=top_p,
|
||||
user=user,
|
||||
models_llm=models_llm,
|
||||
fallback_models=fallback_models,
|
||||
reasoning_effort=reasoning_effort,
|
||||
provider=utils.get_pydantic_model(
|
||||
provider, OptionalNullable[models.ChatCompletionCreateParamsProvider]
|
||||
@@ -541,7 +541,7 @@ class Chat(BaseSDK):
|
||||
] = None,
|
||||
top_p: OptionalNullable[float] = 1,
|
||||
user: Optional[str] = None,
|
||||
models_llm: OptionalNullable[List[str]] = UNSET,
|
||||
fallback_models: OptionalNullable[List[str]] = UNSET,
|
||||
reasoning_effort: OptionalNullable[
|
||||
models.ChatStreamCompletionCreateParamsReasoningEffort
|
||||
] = UNSET,
|
||||
@@ -587,7 +587,7 @@ class Chat(BaseSDK):
|
||||
:param tools: Available tools for function calling
|
||||
:param top_p: Nucleus sampling parameter (0-1)
|
||||
:param user: Unique user identifier
|
||||
:param models_llm: Order of models to fallback to for this request
|
||||
:param fallback_models: Order of models to fallback to for this request
|
||||
:param reasoning_effort: Reasoning effort
|
||||
:param provider: When multiple model providers are available, optionally indicate your routing preference.
|
||||
:param plugins: Plugins you want to enable for this request, including their settings.
|
||||
@@ -643,7 +643,7 @@ class Chat(BaseSDK):
|
||||
),
|
||||
top_p=top_p,
|
||||
user=user,
|
||||
models_llm=models_llm,
|
||||
fallback_models=fallback_models,
|
||||
reasoning_effort=reasoning_effort,
|
||||
provider=utils.get_pydantic_model(
|
||||
provider,
|
||||
@@ -706,6 +706,7 @@ class Chat(BaseSDK):
|
||||
raw, models.StreamChatCompletionResponseBody
|
||||
),
|
||||
sentinel="[DONE]",
|
||||
client_ref=self,
|
||||
)
|
||||
if utils.match_response(http_res, ["400", "401", "429"], "application/json"):
|
||||
http_res_text = utils.stream_to_text(http_res)
|
||||
@@ -792,7 +793,7 @@ class Chat(BaseSDK):
|
||||
] = None,
|
||||
top_p: OptionalNullable[float] = 1,
|
||||
user: Optional[str] = None,
|
||||
models_llm: OptionalNullable[List[str]] = UNSET,
|
||||
fallback_models: OptionalNullable[List[str]] = UNSET,
|
||||
reasoning_effort: OptionalNullable[
|
||||
models.ChatStreamCompletionCreateParamsReasoningEffort
|
||||
] = UNSET,
|
||||
@@ -838,7 +839,7 @@ class Chat(BaseSDK):
|
||||
:param tools: Available tools for function calling
|
||||
:param top_p: Nucleus sampling parameter (0-1)
|
||||
:param user: Unique user identifier
|
||||
:param models_llm: Order of models to fallback to for this request
|
||||
:param fallback_models: Order of models to fallback to for this request
|
||||
:param reasoning_effort: Reasoning effort
|
||||
:param provider: When multiple model providers are available, optionally indicate your routing preference.
|
||||
:param plugins: Plugins you want to enable for this request, including their settings.
|
||||
@@ -894,7 +895,7 @@ class Chat(BaseSDK):
|
||||
),
|
||||
top_p=top_p,
|
||||
user=user,
|
||||
models_llm=models_llm,
|
||||
fallback_models=fallback_models,
|
||||
reasoning_effort=reasoning_effort,
|
||||
provider=utils.get_pydantic_model(
|
||||
provider,
|
||||
@@ -957,6 +958,7 @@ class Chat(BaseSDK):
|
||||
raw, models.StreamChatCompletionResponseBody
|
||||
),
|
||||
sentinel="[DONE]",
|
||||
client_ref=self,
|
||||
)
|
||||
if utils.match_response(http_res, ["400", "401", "429"], "application/json"):
|
||||
http_res_text = await utils.stream_to_text_async(http_res)
|
||||
|
||||
@@ -1,14 +1,15 @@
|
||||
"""Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT."""
|
||||
|
||||
from .openroutererror import OpenRouterError
|
||||
from typing import TYPE_CHECKING
|
||||
from importlib import import_module
|
||||
import builtins
|
||||
import sys
|
||||
|
||||
if TYPE_CHECKING:
|
||||
from .chatcompletionerror import ChatCompletionError, ChatCompletionErrorData
|
||||
from .no_response_error import NoResponseError
|
||||
from .openrouterdefaulterror import OpenRouterDefaultError
|
||||
from .openroutererror import OpenRouterError
|
||||
from .responsevalidationerror import ResponseValidationError
|
||||
|
||||
__all__ = [
|
||||
@@ -25,11 +26,22 @@ _dynamic_imports: dict[str, str] = {
|
||||
"ChatCompletionErrorData": ".chatcompletionerror",
|
||||
"NoResponseError": ".no_response_error",
|
||||
"OpenRouterDefaultError": ".openrouterdefaulterror",
|
||||
"OpenRouterError": ".openroutererror",
|
||||
"ResponseValidationError": ".responsevalidationerror",
|
||||
}
|
||||
|
||||
|
||||
def dynamic_import(modname, retries=3):
|
||||
for attempt in range(retries):
|
||||
try:
|
||||
return import_module(modname, __package__)
|
||||
except KeyError:
|
||||
# Clear any half-initialized module and retry
|
||||
sys.modules.pop(modname, None)
|
||||
if attempt == retries - 1:
|
||||
break
|
||||
raise KeyError(f"Failed to import module '{modname}' after {retries} attempts")
|
||||
|
||||
|
||||
def __getattr__(attr_name: str) -> object:
|
||||
module_name = _dynamic_imports.get(attr_name)
|
||||
if module_name is None:
|
||||
@@ -38,7 +50,7 @@ def __getattr__(attr_name: str) -> object:
|
||||
)
|
||||
|
||||
try:
|
||||
module = import_module(module_name, __package__)
|
||||
module = dynamic_import(module_name)
|
||||
result = getattr(module, attr_name)
|
||||
return result
|
||||
except ImportError as e:
|
||||
|
||||
@@ -3,6 +3,7 @@
|
||||
from typing import TYPE_CHECKING
|
||||
from importlib import import_module
|
||||
import builtins
|
||||
import sys
|
||||
|
||||
if TYPE_CHECKING:
|
||||
from .annotationdetail import AnnotationDetail, AnnotationDetailTypedDict
|
||||
@@ -931,6 +932,18 @@ _dynamic_imports: dict[str, str] = {
|
||||
}
|
||||
|
||||
|
||||
def dynamic_import(modname, retries=3):
|
||||
for attempt in range(retries):
|
||||
try:
|
||||
return import_module(modname, __package__)
|
||||
except KeyError:
|
||||
# Clear any half-initialized module and retry
|
||||
sys.modules.pop(modname, None)
|
||||
if attempt == retries - 1:
|
||||
break
|
||||
raise KeyError(f"Failed to import module '{modname}' after {retries} attempts")
|
||||
|
||||
|
||||
def __getattr__(attr_name: str) -> object:
|
||||
module_name = _dynamic_imports.get(attr_name)
|
||||
if module_name is None:
|
||||
@@ -939,7 +952,7 @@ def __getattr__(attr_name: str) -> object:
|
||||
)
|
||||
|
||||
try:
|
||||
module = import_module(module_name, __package__)
|
||||
module = dynamic_import(module_name)
|
||||
result = getattr(module, attr_name)
|
||||
return result
|
||||
except ImportError as e:
|
||||
|
||||
@@ -3,7 +3,6 @@
|
||||
from __future__ import annotations
|
||||
from .chatcompletionchoice import ChatCompletionChoice, ChatCompletionChoiceTypedDict
|
||||
from .completionusage import CompletionUsage, CompletionUsageTypedDict
|
||||
from enum import Enum
|
||||
from openrouter.types import (
|
||||
BaseModel,
|
||||
Nullable,
|
||||
@@ -12,12 +11,11 @@ from openrouter.types import (
|
||||
UNSET_SENTINEL,
|
||||
)
|
||||
from pydantic import model_serializer
|
||||
from typing import List, Optional
|
||||
from typing import List, Literal, Optional
|
||||
from typing_extensions import NotRequired, TypedDict
|
||||
|
||||
|
||||
class ChatCompletionObject(str, Enum):
|
||||
CHAT_COMPLETION = "chat.completion"
|
||||
ChatCompletionObject = Literal["chat.completion"]
|
||||
|
||||
|
||||
class ChatCompletionTypedDict(TypedDict):
|
||||
|
||||
@@ -9,7 +9,6 @@ from .chatcompletionmessagetoolcall import (
|
||||
ChatCompletionMessageToolCall,
|
||||
ChatCompletionMessageToolCallTypedDict,
|
||||
)
|
||||
from enum import Enum
|
||||
from openrouter.types import (
|
||||
BaseModel,
|
||||
Nullable,
|
||||
@@ -18,13 +17,11 @@ from openrouter.types import (
|
||||
UNSET_SENTINEL,
|
||||
)
|
||||
from pydantic import model_serializer
|
||||
from typing import Any, List, Optional, Union
|
||||
from typing import Any, List, Literal, Optional, Union
|
||||
from typing_extensions import NotRequired, TypeAliasType, TypedDict
|
||||
|
||||
|
||||
class ChatCompletionAssistantMessageParamRole(str, Enum):
|
||||
ASSISTANT = "assistant"
|
||||
|
||||
ChatCompletionAssistantMessageParamRole = Literal["assistant"]
|
||||
|
||||
ChatCompletionAssistantMessageParamContentTypedDict = TypeAliasType(
|
||||
"ChatCompletionAssistantMessageParamContentTypedDict",
|
||||
|
||||
@@ -6,7 +6,6 @@ from .chatcompletiontokenlogprobs import (
|
||||
ChatCompletionTokenLogprobs,
|
||||
ChatCompletionTokenLogprobsTypedDict,
|
||||
)
|
||||
from enum import Enum
|
||||
from openrouter.types import (
|
||||
BaseModel,
|
||||
Nullable,
|
||||
@@ -15,17 +14,14 @@ from openrouter.types import (
|
||||
UNSET_SENTINEL,
|
||||
)
|
||||
from pydantic import model_serializer
|
||||
from typing import Literal
|
||||
from typing_extensions import NotRequired, TypedDict
|
||||
|
||||
|
||||
class ChatCompletionChoiceFinishReason(str, Enum):
|
||||
r"""Reason the completion finished"""
|
||||
|
||||
TOOL_CALLS = "tool_calls"
|
||||
STOP = "stop"
|
||||
LENGTH = "length"
|
||||
CONTENT_FILTER = "content_filter"
|
||||
ERROR = "error"
|
||||
ChatCompletionChoiceFinishReason = Literal[
|
||||
"tool_calls", "stop", "length", "content_filter", "error"
|
||||
]
|
||||
r"""Reason the completion finished"""
|
||||
|
||||
|
||||
class ChatCompletionChoiceTypedDict(TypedDict):
|
||||
|
||||
@@ -6,7 +6,6 @@ from .chatcompletionchunkchoice import (
|
||||
ChatCompletionChunkChoiceTypedDict,
|
||||
)
|
||||
from .completionusage import CompletionUsage, CompletionUsageTypedDict
|
||||
from enum import Enum
|
||||
from openrouter.types import (
|
||||
BaseModel,
|
||||
Nullable,
|
||||
@@ -15,12 +14,11 @@ from openrouter.types import (
|
||||
UNSET_SENTINEL,
|
||||
)
|
||||
from pydantic import model_serializer
|
||||
from typing import List, Optional
|
||||
from typing import List, Literal, Optional
|
||||
from typing_extensions import NotRequired, TypedDict
|
||||
|
||||
|
||||
class ChatCompletionChunkObject(str, Enum):
|
||||
CHAT_COMPLETION_CHUNK = "chat.completion.chunk"
|
||||
ChatCompletionChunkObject = Literal["chat.completion.chunk"]
|
||||
|
||||
|
||||
class ChatCompletionChunkTypedDict(TypedDict):
|
||||
|
||||
@@ -9,7 +9,6 @@ from .chatcompletiontokenlogprobs import (
|
||||
ChatCompletionTokenLogprobs,
|
||||
ChatCompletionTokenLogprobsTypedDict,
|
||||
)
|
||||
from enum import Enum
|
||||
from openrouter.types import (
|
||||
BaseModel,
|
||||
Nullable,
|
||||
@@ -18,15 +17,13 @@ from openrouter.types import (
|
||||
UNSET_SENTINEL,
|
||||
)
|
||||
from pydantic import model_serializer
|
||||
from typing import Literal
|
||||
from typing_extensions import NotRequired, TypedDict
|
||||
|
||||
|
||||
class ChatCompletionChunkChoiceFinishReason(str, Enum):
|
||||
TOOL_CALLS = "tool_calls"
|
||||
STOP = "stop"
|
||||
LENGTH = "length"
|
||||
CONTENT_FILTER = "content_filter"
|
||||
ERROR = "error"
|
||||
ChatCompletionChunkChoiceFinishReason = Literal[
|
||||
"tool_calls", "stop", "length", "content_filter", "error"
|
||||
]
|
||||
|
||||
|
||||
class ChatCompletionChunkChoiceTypedDict(TypedDict):
|
||||
|
||||
@@ -7,7 +7,6 @@ from .chatcompletionchunkchoicedeltatoolcall import (
|
||||
ChatCompletionChunkChoiceDeltaToolCallTypedDict,
|
||||
)
|
||||
from .reasoningdetail import ReasoningDetail, ReasoningDetailTypedDict
|
||||
from enum import Enum
|
||||
from openrouter.types import (
|
||||
BaseModel,
|
||||
Nullable,
|
||||
@@ -16,14 +15,12 @@ from openrouter.types import (
|
||||
UNSET_SENTINEL,
|
||||
)
|
||||
from pydantic import model_serializer
|
||||
from typing import List, Optional
|
||||
from typing import List, Literal, Optional
|
||||
from typing_extensions import NotRequired, TypedDict
|
||||
|
||||
|
||||
class ChatCompletionChunkChoiceDeltaRole(str, Enum):
|
||||
r"""The role of the message author"""
|
||||
|
||||
ASSISTANT = "assistant"
|
||||
ChatCompletionChunkChoiceDeltaRole = Literal["assistant"]
|
||||
r"""The role of the message author"""
|
||||
|
||||
|
||||
class ChatCompletionChunkChoiceDeltaTypedDict(TypedDict):
|
||||
|
||||
@@ -1,16 +1,13 @@
|
||||
"""Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT."""
|
||||
|
||||
from __future__ import annotations
|
||||
from enum import Enum
|
||||
from openrouter.types import BaseModel
|
||||
from typing import Optional
|
||||
from typing import Literal, Optional
|
||||
from typing_extensions import NotRequired, TypedDict
|
||||
|
||||
|
||||
class ChatCompletionChunkChoiceDeltaToolCallType(str, Enum):
|
||||
r"""Tool call type"""
|
||||
|
||||
FUNCTION = "function"
|
||||
ChatCompletionChunkChoiceDeltaToolCallType = Literal["function"]
|
||||
r"""Tool call type"""
|
||||
|
||||
|
||||
class ChatCompletionChunkChoiceDeltaToolCallFunctionTypedDict(TypedDict):
|
||||
|
||||
@@ -1,26 +1,18 @@
|
||||
"""Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT."""
|
||||
|
||||
from __future__ import annotations
|
||||
from enum import Enum
|
||||
from openrouter.types import BaseModel
|
||||
import pydantic
|
||||
from typing import Literal
|
||||
from typing_extensions import Annotated, TypedDict
|
||||
|
||||
|
||||
class ChatCompletionContentPartAudioType(str, Enum):
|
||||
INPUT_AUDIO = "input_audio"
|
||||
ChatCompletionContentPartAudioType = Literal["input_audio"]
|
||||
|
||||
|
||||
class ChatCompletionContentPartAudioFormat(str, Enum):
|
||||
r"""Audio format"""
|
||||
|
||||
WAV = "wav"
|
||||
MP3 = "mp3"
|
||||
FLAC = "flac"
|
||||
M4A = "m4a"
|
||||
OGG = "ogg"
|
||||
PCM16 = "pcm16"
|
||||
PCM24 = "pcm24"
|
||||
ChatCompletionContentPartAudioFormat = Literal[
|
||||
"wav", "mp3", "flac", "m4a", "ogg", "pcm16", "pcm24"
|
||||
]
|
||||
r"""Audio format"""
|
||||
|
||||
|
||||
class InputAudioTypedDict(TypedDict):
|
||||
|
||||
@@ -1,22 +1,15 @@
|
||||
"""Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT."""
|
||||
|
||||
from __future__ import annotations
|
||||
from enum import Enum
|
||||
from openrouter.types import BaseModel
|
||||
from typing import Optional
|
||||
from typing import Literal, Optional
|
||||
from typing_extensions import NotRequired, TypedDict
|
||||
|
||||
|
||||
class ChatCompletionContentPartImageType(str, Enum):
|
||||
IMAGE_URL = "image_url"
|
||||
ChatCompletionContentPartImageType = Literal["image_url"]
|
||||
|
||||
|
||||
class Detail(str, Enum):
|
||||
r"""Image detail level for vision models"""
|
||||
|
||||
AUTO = "auto"
|
||||
LOW = "low"
|
||||
HIGH = "high"
|
||||
Detail = Literal["auto", "low", "high"]
|
||||
r"""Image detail level for vision models"""
|
||||
|
||||
|
||||
class ChatCompletionContentPartImageImageURLTypedDict(TypedDict):
|
||||
|
||||
@@ -1,13 +1,12 @@
|
||||
"""Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT."""
|
||||
|
||||
from __future__ import annotations
|
||||
from enum import Enum
|
||||
from openrouter.types import BaseModel
|
||||
from typing import Literal
|
||||
from typing_extensions import TypedDict
|
||||
|
||||
|
||||
class ChatCompletionContentPartTextType(str, Enum):
|
||||
TEXT = "text"
|
||||
ChatCompletionContentPartTextType = Literal["text"]
|
||||
|
||||
|
||||
class ChatCompletionContentPartTextTypedDict(TypedDict):
|
||||
|
||||
@@ -14,7 +14,6 @@ from .responseformatjsonschemaschema import (
|
||||
ResponseFormatJSONSchemaSchema,
|
||||
ResponseFormatJSONSchemaSchemaTypedDict,
|
||||
)
|
||||
from enum import Enum
|
||||
from openrouter.types import (
|
||||
BaseModel,
|
||||
Nullable,
|
||||
@@ -24,17 +23,12 @@ from openrouter.types import (
|
||||
)
|
||||
import pydantic
|
||||
from pydantic import model_serializer
|
||||
from typing import Any, Dict, List, Optional, Union
|
||||
from typing import Any, Dict, List, Literal, Optional, Union
|
||||
from typing_extensions import Annotated, NotRequired, TypeAliasType, TypedDict
|
||||
|
||||
|
||||
class ChatCompletionCreateParamsEffort(str, Enum):
|
||||
r"""OpenAI-style reasoning effort setting"""
|
||||
|
||||
HIGH = "high"
|
||||
MEDIUM = "medium"
|
||||
LOW = "low"
|
||||
MINIMAL = "minimal"
|
||||
ChatCompletionCreateParamsEffort = Literal["high", "medium", "low", "minimal"]
|
||||
r"""OpenAI-style reasoning effort setting"""
|
||||
|
||||
|
||||
class ChatCompletionCreateParamsReasoningTypedDict(TypedDict):
|
||||
@@ -94,8 +88,7 @@ class ChatCompletionCreateParamsReasoning(BaseModel):
|
||||
return m
|
||||
|
||||
|
||||
class ChatCompletionCreateParamsTypePython(str, Enum):
|
||||
PYTHON = "python"
|
||||
ChatCompletionCreateParamsTypePython = Literal["python"]
|
||||
|
||||
|
||||
class ChatCompletionCreateParamsResponseFormatPythonTypedDict(TypedDict):
|
||||
@@ -110,8 +103,7 @@ class ChatCompletionCreateParamsResponseFormatPython(BaseModel):
|
||||
type: ChatCompletionCreateParamsTypePython
|
||||
|
||||
|
||||
class ChatCompletionCreateParamsTypeGrammar(str, Enum):
|
||||
GRAMMAR = "grammar"
|
||||
ChatCompletionCreateParamsTypeGrammar = Literal["grammar"]
|
||||
|
||||
|
||||
class ChatCompletionCreateParamsResponseFormatGrammarTypedDict(TypedDict):
|
||||
@@ -131,8 +123,7 @@ class ChatCompletionCreateParamsResponseFormatGrammar(BaseModel):
|
||||
r"""Custom grammar for text generation"""
|
||||
|
||||
|
||||
class ChatCompletionCreateParamsTypeJSONSchema(str, Enum):
|
||||
JSON_SCHEMA = "json_schema"
|
||||
ChatCompletionCreateParamsTypeJSONSchema = Literal["json_schema"]
|
||||
|
||||
|
||||
class ChatCompletionCreateParamsJSONSchemaTypedDict(TypedDict):
|
||||
@@ -207,8 +198,7 @@ class ChatCompletionCreateParamsResponseFormatJSONSchema(BaseModel):
|
||||
json_schema: ChatCompletionCreateParamsJSONSchema
|
||||
|
||||
|
||||
class ChatCompletionCreateParamsTypeJSONObject(str, Enum):
|
||||
JSON_OBJECT = "json_object"
|
||||
ChatCompletionCreateParamsTypeJSONObject = Literal["json_object"]
|
||||
|
||||
|
||||
class ChatCompletionCreateParamsResponseFormatJSONObjectTypedDict(TypedDict):
|
||||
@@ -223,8 +213,7 @@ class ChatCompletionCreateParamsResponseFormatJSONObject(BaseModel):
|
||||
type: ChatCompletionCreateParamsTypeJSONObject
|
||||
|
||||
|
||||
class ChatCompletionCreateParamsTypeText(str, Enum):
|
||||
TEXT = "text"
|
||||
ChatCompletionCreateParamsTypeText = Literal["text"]
|
||||
|
||||
|
||||
class ChatCompletionCreateParamsResponseFormatTextTypedDict(TypedDict):
|
||||
@@ -291,106 +280,96 @@ class ChatCompletionCreateParamsStreamOptions(BaseModel):
|
||||
r"""Include usage information in streaming response"""
|
||||
|
||||
|
||||
class ChatCompletionCreateParamsReasoningEffort(str, Enum):
|
||||
r"""Reasoning effort"""
|
||||
ChatCompletionCreateParamsReasoningEffort = Literal["high", "medium", "low", "minimal"]
|
||||
r"""Reasoning effort"""
|
||||
|
||||
HIGH = "high"
|
||||
MEDIUM = "medium"
|
||||
LOW = "low"
|
||||
MINIMAL = "minimal"
|
||||
ChatCompletionCreateParamsDataCollection = Literal["deny", "allow"]
|
||||
r"""Data collection setting. If no available model provider meets the requirement, your request will return an error.
|
||||
- allow: (default) allow providers which store user data non-transiently and may train on it
|
||||
- deny: use only providers which do not collect user data.
|
||||
|
||||
"""
|
||||
|
||||
class ChatCompletionCreateParamsDataCollection(str, Enum):
|
||||
r"""Data collection setting. If no available model provider meets the requirement, your request will return an error.
|
||||
- allow: (default) allow providers which store user data non-transiently and may train on it
|
||||
- deny: use only providers which do not collect user data.
|
||||
|
||||
"""
|
||||
|
||||
DENY = "deny"
|
||||
ALLOW = "allow"
|
||||
|
||||
|
||||
class ChatCompletionCreateParamsOrderEnum(str, Enum):
|
||||
ANY_SCALE = "AnyScale"
|
||||
CENT_ML = "Cent-ML"
|
||||
HUGGING_FACE = "HuggingFace"
|
||||
HYPERBOLIC_2 = "Hyperbolic 2"
|
||||
LEPTON = "Lepton"
|
||||
LYNN_2 = "Lynn 2"
|
||||
LYNN = "Lynn"
|
||||
MANCER = "Mancer"
|
||||
MODAL = "Modal"
|
||||
OCTO_AI = "OctoAI"
|
||||
RECURSAL = "Recursal"
|
||||
REFLECTION = "Reflection"
|
||||
REPLICATE = "Replicate"
|
||||
SAMBA_NOVA_2 = "SambaNova 2"
|
||||
SF_COMPUTE = "SF Compute"
|
||||
TOGETHER_2 = "Together 2"
|
||||
ONE_DOT_AI = "01.AI"
|
||||
AI21 = "AI21"
|
||||
AION_LABS = "AionLabs"
|
||||
ALIBABA = "Alibaba"
|
||||
AMAZON_BEDROCK = "Amazon Bedrock"
|
||||
ANTHROPIC = "Anthropic"
|
||||
ATLAS_CLOUD = "AtlasCloud"
|
||||
ATOMA = "Atoma"
|
||||
AVIAN = "Avian"
|
||||
AZURE = "Azure"
|
||||
BASE_TEN = "BaseTen"
|
||||
CEREBRAS = "Cerebras"
|
||||
CHUTES = "Chutes"
|
||||
CLOUDFLARE = "Cloudflare"
|
||||
COHERE = "Cohere"
|
||||
CROF_AI = "CrofAI"
|
||||
CRUSOE = "Crusoe"
|
||||
DEEP_INFRA = "DeepInfra"
|
||||
DEEP_SEEK = "DeepSeek"
|
||||
ENFER = "Enfer"
|
||||
FEATHERLESS = "Featherless"
|
||||
FIREWORKS = "Fireworks"
|
||||
FRIENDLI = "Friendli"
|
||||
GMI_CLOUD = "GMICloud"
|
||||
GOOGLE = "Google"
|
||||
GOOGLE_AI_STUDIO = "Google AI Studio"
|
||||
GROQ = "Groq"
|
||||
HYPERBOLIC = "Hyperbolic"
|
||||
INCEPTION = "Inception"
|
||||
INFERENCE_NET = "InferenceNet"
|
||||
INFERMATIC = "Infermatic"
|
||||
INFLECTION = "Inflection"
|
||||
INO_CLOUD = "InoCloud"
|
||||
KLUSTER = "Kluster"
|
||||
LAMBDA = "Lambda"
|
||||
LIQUID = "Liquid"
|
||||
MANCER_2 = "Mancer 2"
|
||||
META = "Meta"
|
||||
MINIMAX = "Minimax"
|
||||
MISTRAL = "Mistral"
|
||||
MOONSHOT_AI = "Moonshot AI"
|
||||
MORPH = "Morph"
|
||||
N_COMPASS = "NCompass"
|
||||
NEBIUS = "Nebius"
|
||||
NEXT_BIT = "NextBit"
|
||||
NINETEEN = "Nineteen"
|
||||
NOVITA = "Novita"
|
||||
OPEN_AI = "OpenAI"
|
||||
OPEN_INFERENCE = "OpenInference"
|
||||
PARASAIL = "Parasail"
|
||||
PERPLEXITY = "Perplexity"
|
||||
PHALA = "Phala"
|
||||
SAMBA_NOVA = "SambaNova"
|
||||
STEALTH = "Stealth"
|
||||
SWITCHPOINT = "Switchpoint"
|
||||
TARGON = "Targon"
|
||||
TOGETHER = "Together"
|
||||
UBICLOUD = "Ubicloud"
|
||||
VENICE = "Venice"
|
||||
WAND_B = "WandB"
|
||||
X_AI = "xAI"
|
||||
Z_AI = "Z.AI"
|
||||
|
||||
ChatCompletionCreateParamsOrderEnum = Literal[
|
||||
"AnyScale",
|
||||
"Cent-ML",
|
||||
"HuggingFace",
|
||||
"Hyperbolic 2",
|
||||
"Lepton",
|
||||
"Lynn 2",
|
||||
"Lynn",
|
||||
"Mancer",
|
||||
"Modal",
|
||||
"OctoAI",
|
||||
"Recursal",
|
||||
"Reflection",
|
||||
"Replicate",
|
||||
"SambaNova 2",
|
||||
"SF Compute",
|
||||
"Together 2",
|
||||
"01.AI",
|
||||
"AI21",
|
||||
"AionLabs",
|
||||
"Alibaba",
|
||||
"Amazon Bedrock",
|
||||
"Anthropic",
|
||||
"AtlasCloud",
|
||||
"Atoma",
|
||||
"Avian",
|
||||
"Azure",
|
||||
"BaseTen",
|
||||
"Cerebras",
|
||||
"Chutes",
|
||||
"Cloudflare",
|
||||
"Cohere",
|
||||
"CrofAI",
|
||||
"Crusoe",
|
||||
"DeepInfra",
|
||||
"DeepSeek",
|
||||
"Enfer",
|
||||
"Featherless",
|
||||
"Fireworks",
|
||||
"Friendli",
|
||||
"GMICloud",
|
||||
"Google",
|
||||
"Google AI Studio",
|
||||
"Groq",
|
||||
"Hyperbolic",
|
||||
"Inception",
|
||||
"InferenceNet",
|
||||
"Infermatic",
|
||||
"Inflection",
|
||||
"InoCloud",
|
||||
"Kluster",
|
||||
"Lambda",
|
||||
"Liquid",
|
||||
"Mancer 2",
|
||||
"Meta",
|
||||
"Minimax",
|
||||
"Mistral",
|
||||
"Moonshot AI",
|
||||
"Morph",
|
||||
"NCompass",
|
||||
"Nebius",
|
||||
"NextBit",
|
||||
"Nineteen",
|
||||
"Novita",
|
||||
"OpenAI",
|
||||
"OpenInference",
|
||||
"Parasail",
|
||||
"Perplexity",
|
||||
"Phala",
|
||||
"SambaNova",
|
||||
"Stealth",
|
||||
"Switchpoint",
|
||||
"Targon",
|
||||
"Together",
|
||||
"Ubicloud",
|
||||
"Venice",
|
||||
"WandB",
|
||||
"xAI",
|
||||
"Z.AI",
|
||||
]
|
||||
|
||||
ChatCompletionCreateParamsOrderUnionTypedDict = TypeAliasType(
|
||||
"ChatCompletionCreateParamsOrderUnionTypedDict",
|
||||
@@ -404,86 +383,86 @@ ChatCompletionCreateParamsOrderUnion = TypeAliasType(
|
||||
)
|
||||
|
||||
|
||||
class ChatCompletionCreateParamsOnlyEnum(str, Enum):
|
||||
ANY_SCALE = "AnyScale"
|
||||
CENT_ML = "Cent-ML"
|
||||
HUGGING_FACE = "HuggingFace"
|
||||
HYPERBOLIC_2 = "Hyperbolic 2"
|
||||
LEPTON = "Lepton"
|
||||
LYNN_2 = "Lynn 2"
|
||||
LYNN = "Lynn"
|
||||
MANCER = "Mancer"
|
||||
MODAL = "Modal"
|
||||
OCTO_AI = "OctoAI"
|
||||
RECURSAL = "Recursal"
|
||||
REFLECTION = "Reflection"
|
||||
REPLICATE = "Replicate"
|
||||
SAMBA_NOVA_2 = "SambaNova 2"
|
||||
SF_COMPUTE = "SF Compute"
|
||||
TOGETHER_2 = "Together 2"
|
||||
ONE_DOT_AI = "01.AI"
|
||||
AI21 = "AI21"
|
||||
AION_LABS = "AionLabs"
|
||||
ALIBABA = "Alibaba"
|
||||
AMAZON_BEDROCK = "Amazon Bedrock"
|
||||
ANTHROPIC = "Anthropic"
|
||||
ATLAS_CLOUD = "AtlasCloud"
|
||||
ATOMA = "Atoma"
|
||||
AVIAN = "Avian"
|
||||
AZURE = "Azure"
|
||||
BASE_TEN = "BaseTen"
|
||||
CEREBRAS = "Cerebras"
|
||||
CHUTES = "Chutes"
|
||||
CLOUDFLARE = "Cloudflare"
|
||||
COHERE = "Cohere"
|
||||
CROF_AI = "CrofAI"
|
||||
CRUSOE = "Crusoe"
|
||||
DEEP_INFRA = "DeepInfra"
|
||||
DEEP_SEEK = "DeepSeek"
|
||||
ENFER = "Enfer"
|
||||
FEATHERLESS = "Featherless"
|
||||
FIREWORKS = "Fireworks"
|
||||
FRIENDLI = "Friendli"
|
||||
GMI_CLOUD = "GMICloud"
|
||||
GOOGLE = "Google"
|
||||
GOOGLE_AI_STUDIO = "Google AI Studio"
|
||||
GROQ = "Groq"
|
||||
HYPERBOLIC = "Hyperbolic"
|
||||
INCEPTION = "Inception"
|
||||
INFERENCE_NET = "InferenceNet"
|
||||
INFERMATIC = "Infermatic"
|
||||
INFLECTION = "Inflection"
|
||||
INO_CLOUD = "InoCloud"
|
||||
KLUSTER = "Kluster"
|
||||
LAMBDA = "Lambda"
|
||||
LIQUID = "Liquid"
|
||||
MANCER_2 = "Mancer 2"
|
||||
META = "Meta"
|
||||
MINIMAX = "Minimax"
|
||||
MISTRAL = "Mistral"
|
||||
MOONSHOT_AI = "Moonshot AI"
|
||||
MORPH = "Morph"
|
||||
N_COMPASS = "NCompass"
|
||||
NEBIUS = "Nebius"
|
||||
NEXT_BIT = "NextBit"
|
||||
NINETEEN = "Nineteen"
|
||||
NOVITA = "Novita"
|
||||
OPEN_AI = "OpenAI"
|
||||
OPEN_INFERENCE = "OpenInference"
|
||||
PARASAIL = "Parasail"
|
||||
PERPLEXITY = "Perplexity"
|
||||
PHALA = "Phala"
|
||||
SAMBA_NOVA = "SambaNova"
|
||||
STEALTH = "Stealth"
|
||||
SWITCHPOINT = "Switchpoint"
|
||||
TARGON = "Targon"
|
||||
TOGETHER = "Together"
|
||||
UBICLOUD = "Ubicloud"
|
||||
VENICE = "Venice"
|
||||
WAND_B = "WandB"
|
||||
X_AI = "xAI"
|
||||
Z_AI = "Z.AI"
|
||||
|
||||
ChatCompletionCreateParamsOnlyEnum = Literal[
|
||||
"AnyScale",
|
||||
"Cent-ML",
|
||||
"HuggingFace",
|
||||
"Hyperbolic 2",
|
||||
"Lepton",
|
||||
"Lynn 2",
|
||||
"Lynn",
|
||||
"Mancer",
|
||||
"Modal",
|
||||
"OctoAI",
|
||||
"Recursal",
|
||||
"Reflection",
|
||||
"Replicate",
|
||||
"SambaNova 2",
|
||||
"SF Compute",
|
||||
"Together 2",
|
||||
"01.AI",
|
||||
"AI21",
|
||||
"AionLabs",
|
||||
"Alibaba",
|
||||
"Amazon Bedrock",
|
||||
"Anthropic",
|
||||
"AtlasCloud",
|
||||
"Atoma",
|
||||
"Avian",
|
||||
"Azure",
|
||||
"BaseTen",
|
||||
"Cerebras",
|
||||
"Chutes",
|
||||
"Cloudflare",
|
||||
"Cohere",
|
||||
"CrofAI",
|
||||
"Crusoe",
|
||||
"DeepInfra",
|
||||
"DeepSeek",
|
||||
"Enfer",
|
||||
"Featherless",
|
||||
"Fireworks",
|
||||
"Friendli",
|
||||
"GMICloud",
|
||||
"Google",
|
||||
"Google AI Studio",
|
||||
"Groq",
|
||||
"Hyperbolic",
|
||||
"Inception",
|
||||
"InferenceNet",
|
||||
"Infermatic",
|
||||
"Inflection",
|
||||
"InoCloud",
|
||||
"Kluster",
|
||||
"Lambda",
|
||||
"Liquid",
|
||||
"Mancer 2",
|
||||
"Meta",
|
||||
"Minimax",
|
||||
"Mistral",
|
||||
"Moonshot AI",
|
||||
"Morph",
|
||||
"NCompass",
|
||||
"Nebius",
|
||||
"NextBit",
|
||||
"Nineteen",
|
||||
"Novita",
|
||||
"OpenAI",
|
||||
"OpenInference",
|
||||
"Parasail",
|
||||
"Perplexity",
|
||||
"Phala",
|
||||
"SambaNova",
|
||||
"Stealth",
|
||||
"Switchpoint",
|
||||
"Targon",
|
||||
"Together",
|
||||
"Ubicloud",
|
||||
"Venice",
|
||||
"WandB",
|
||||
"xAI",
|
||||
"Z.AI",
|
||||
]
|
||||
|
||||
ChatCompletionCreateParamsOnlyUnionTypedDict = TypeAliasType(
|
||||
"ChatCompletionCreateParamsOnlyUnionTypedDict",
|
||||
@@ -497,86 +476,86 @@ ChatCompletionCreateParamsOnlyUnion = TypeAliasType(
|
||||
)
|
||||
|
||||
|
||||
class ChatCompletionCreateParamsIgnoreEnum(str, Enum):
|
||||
ANY_SCALE = "AnyScale"
|
||||
CENT_ML = "Cent-ML"
|
||||
HUGGING_FACE = "HuggingFace"
|
||||
HYPERBOLIC_2 = "Hyperbolic 2"
|
||||
LEPTON = "Lepton"
|
||||
LYNN_2 = "Lynn 2"
|
||||
LYNN = "Lynn"
|
||||
MANCER = "Mancer"
|
||||
MODAL = "Modal"
|
||||
OCTO_AI = "OctoAI"
|
||||
RECURSAL = "Recursal"
|
||||
REFLECTION = "Reflection"
|
||||
REPLICATE = "Replicate"
|
||||
SAMBA_NOVA_2 = "SambaNova 2"
|
||||
SF_COMPUTE = "SF Compute"
|
||||
TOGETHER_2 = "Together 2"
|
||||
ONE_DOT_AI = "01.AI"
|
||||
AI21 = "AI21"
|
||||
AION_LABS = "AionLabs"
|
||||
ALIBABA = "Alibaba"
|
||||
AMAZON_BEDROCK = "Amazon Bedrock"
|
||||
ANTHROPIC = "Anthropic"
|
||||
ATLAS_CLOUD = "AtlasCloud"
|
||||
ATOMA = "Atoma"
|
||||
AVIAN = "Avian"
|
||||
AZURE = "Azure"
|
||||
BASE_TEN = "BaseTen"
|
||||
CEREBRAS = "Cerebras"
|
||||
CHUTES = "Chutes"
|
||||
CLOUDFLARE = "Cloudflare"
|
||||
COHERE = "Cohere"
|
||||
CROF_AI = "CrofAI"
|
||||
CRUSOE = "Crusoe"
|
||||
DEEP_INFRA = "DeepInfra"
|
||||
DEEP_SEEK = "DeepSeek"
|
||||
ENFER = "Enfer"
|
||||
FEATHERLESS = "Featherless"
|
||||
FIREWORKS = "Fireworks"
|
||||
FRIENDLI = "Friendli"
|
||||
GMI_CLOUD = "GMICloud"
|
||||
GOOGLE = "Google"
|
||||
GOOGLE_AI_STUDIO = "Google AI Studio"
|
||||
GROQ = "Groq"
|
||||
HYPERBOLIC = "Hyperbolic"
|
||||
INCEPTION = "Inception"
|
||||
INFERENCE_NET = "InferenceNet"
|
||||
INFERMATIC = "Infermatic"
|
||||
INFLECTION = "Inflection"
|
||||
INO_CLOUD = "InoCloud"
|
||||
KLUSTER = "Kluster"
|
||||
LAMBDA = "Lambda"
|
||||
LIQUID = "Liquid"
|
||||
MANCER_2 = "Mancer 2"
|
||||
META = "Meta"
|
||||
MINIMAX = "Minimax"
|
||||
MISTRAL = "Mistral"
|
||||
MOONSHOT_AI = "Moonshot AI"
|
||||
MORPH = "Morph"
|
||||
N_COMPASS = "NCompass"
|
||||
NEBIUS = "Nebius"
|
||||
NEXT_BIT = "NextBit"
|
||||
NINETEEN = "Nineteen"
|
||||
NOVITA = "Novita"
|
||||
OPEN_AI = "OpenAI"
|
||||
OPEN_INFERENCE = "OpenInference"
|
||||
PARASAIL = "Parasail"
|
||||
PERPLEXITY = "Perplexity"
|
||||
PHALA = "Phala"
|
||||
SAMBA_NOVA = "SambaNova"
|
||||
STEALTH = "Stealth"
|
||||
SWITCHPOINT = "Switchpoint"
|
||||
TARGON = "Targon"
|
||||
TOGETHER = "Together"
|
||||
UBICLOUD = "Ubicloud"
|
||||
VENICE = "Venice"
|
||||
WAND_B = "WandB"
|
||||
X_AI = "xAI"
|
||||
Z_AI = "Z.AI"
|
||||
|
||||
ChatCompletionCreateParamsIgnoreEnum = Literal[
|
||||
"AnyScale",
|
||||
"Cent-ML",
|
||||
"HuggingFace",
|
||||
"Hyperbolic 2",
|
||||
"Lepton",
|
||||
"Lynn 2",
|
||||
"Lynn",
|
||||
"Mancer",
|
||||
"Modal",
|
||||
"OctoAI",
|
||||
"Recursal",
|
||||
"Reflection",
|
||||
"Replicate",
|
||||
"SambaNova 2",
|
||||
"SF Compute",
|
||||
"Together 2",
|
||||
"01.AI",
|
||||
"AI21",
|
||||
"AionLabs",
|
||||
"Alibaba",
|
||||
"Amazon Bedrock",
|
||||
"Anthropic",
|
||||
"AtlasCloud",
|
||||
"Atoma",
|
||||
"Avian",
|
||||
"Azure",
|
||||
"BaseTen",
|
||||
"Cerebras",
|
||||
"Chutes",
|
||||
"Cloudflare",
|
||||
"Cohere",
|
||||
"CrofAI",
|
||||
"Crusoe",
|
||||
"DeepInfra",
|
||||
"DeepSeek",
|
||||
"Enfer",
|
||||
"Featherless",
|
||||
"Fireworks",
|
||||
"Friendli",
|
||||
"GMICloud",
|
||||
"Google",
|
||||
"Google AI Studio",
|
||||
"Groq",
|
||||
"Hyperbolic",
|
||||
"Inception",
|
||||
"InferenceNet",
|
||||
"Infermatic",
|
||||
"Inflection",
|
||||
"InoCloud",
|
||||
"Kluster",
|
||||
"Lambda",
|
||||
"Liquid",
|
||||
"Mancer 2",
|
||||
"Meta",
|
||||
"Minimax",
|
||||
"Mistral",
|
||||
"Moonshot AI",
|
||||
"Morph",
|
||||
"NCompass",
|
||||
"Nebius",
|
||||
"NextBit",
|
||||
"Nineteen",
|
||||
"Novita",
|
||||
"OpenAI",
|
||||
"OpenInference",
|
||||
"Parasail",
|
||||
"Perplexity",
|
||||
"Phala",
|
||||
"SambaNova",
|
||||
"Stealth",
|
||||
"Switchpoint",
|
||||
"Targon",
|
||||
"Together",
|
||||
"Ubicloud",
|
||||
"Venice",
|
||||
"WandB",
|
||||
"xAI",
|
||||
"Z.AI",
|
||||
]
|
||||
|
||||
ChatCompletionCreateParamsIgnoreUnionTypedDict = TypeAliasType(
|
||||
"ChatCompletionCreateParamsIgnoreUnionTypedDict",
|
||||
@@ -590,25 +569,12 @@ ChatCompletionCreateParamsIgnoreUnion = TypeAliasType(
|
||||
)
|
||||
|
||||
|
||||
class ChatCompletionCreateParamsQuantization(str, Enum):
|
||||
INT4 = "int4"
|
||||
INT8 = "int8"
|
||||
FP4 = "fp4"
|
||||
FP6 = "fp6"
|
||||
FP8 = "fp8"
|
||||
FP16 = "fp16"
|
||||
BF16 = "bf16"
|
||||
FP32 = "fp32"
|
||||
UNKNOWN = "unknown"
|
||||
|
||||
|
||||
class ChatCompletionCreateParamsSort(str, Enum):
|
||||
r"""The sorting strategy to use for this request, if \"order\" is not specified. When set, no load balancing is performed."""
|
||||
|
||||
PRICE = "price"
|
||||
THROUGHPUT = "throughput"
|
||||
LATENCY = "latency"
|
||||
ChatCompletionCreateParamsQuantization = Literal[
|
||||
"int4", "int8", "fp4", "fp6", "fp8", "fp16", "bf16", "fp32", "unknown"
|
||||
]
|
||||
|
||||
ChatCompletionCreateParamsSort = Literal["price", "throughput", "latency"]
|
||||
r"""The sorting strategy to use for this request, if \"order\" is not specified. When set, no load balancing is performed."""
|
||||
|
||||
ChatCompletionCreateParamsPromptTypedDict = TypeAliasType(
|
||||
"ChatCompletionCreateParamsPromptTypedDict", Union[float, str, Any]
|
||||
@@ -805,14 +771,9 @@ class ChatCompletionCreateParamsProvider(BaseModel):
|
||||
return m
|
||||
|
||||
|
||||
class ChatCompletionCreateParamsIDFileParser(str, Enum):
|
||||
FILE_PARSER = "file-parser"
|
||||
ChatCompletionCreateParamsIDFileParser = Literal["file-parser"]
|
||||
|
||||
|
||||
class ChatCompletionCreateParamsPdfEngine(str, Enum):
|
||||
MISTRAL_OCR = "mistral-ocr"
|
||||
PDF_TEXT = "pdf-text"
|
||||
NATIVE = "native"
|
||||
ChatCompletionCreateParamsPdfEngine = Literal["mistral-ocr", "pdf-text", "native"]
|
||||
|
||||
|
||||
class ChatCompletionCreateParamsPdfTypedDict(TypedDict):
|
||||
@@ -837,8 +798,7 @@ class ChatCompletionCreateParamsPluginFileParser(BaseModel):
|
||||
pdf: Optional[ChatCompletionCreateParamsPdf] = None
|
||||
|
||||
|
||||
class ChatCompletionCreateParamsIDChainOfThought(str, Enum):
|
||||
CHAIN_OF_THOUGHT = "chain-of-thought"
|
||||
ChatCompletionCreateParamsIDChainOfThought = Literal["chain-of-thought"]
|
||||
|
||||
|
||||
class ChatCompletionCreateParamsPluginChainOfThoughtTypedDict(TypedDict):
|
||||
@@ -849,13 +809,9 @@ class ChatCompletionCreateParamsPluginChainOfThought(BaseModel):
|
||||
id: ChatCompletionCreateParamsIDChainOfThought
|
||||
|
||||
|
||||
class ChatCompletionCreateParamsIDWeb(str, Enum):
|
||||
WEB = "web"
|
||||
ChatCompletionCreateParamsIDWeb = Literal["web"]
|
||||
|
||||
|
||||
class ChatCompletionCreateParamsEngine(str, Enum):
|
||||
NATIVE = "native"
|
||||
EXA = "exa"
|
||||
ChatCompletionCreateParamsEngine = Literal["native", "exa"]
|
||||
|
||||
|
||||
class ChatCompletionCreateParamsPluginWebTypedDict(TypedDict):
|
||||
@@ -875,8 +831,7 @@ class ChatCompletionCreateParamsPluginWeb(BaseModel):
|
||||
engine: Optional[ChatCompletionCreateParamsEngine] = None
|
||||
|
||||
|
||||
class ChatCompletionCreateParamsIDModeration(str, Enum):
|
||||
MODERATION = "moderation"
|
||||
ChatCompletionCreateParamsIDModeration = Literal["moderation"]
|
||||
|
||||
|
||||
class ChatCompletionCreateParamsPluginModerationTypedDict(TypedDict):
|
||||
@@ -955,7 +910,7 @@ class ChatCompletionCreateParamsTypedDict(TypedDict):
|
||||
r"""Nucleus sampling parameter (0-1)"""
|
||||
user: NotRequired[str]
|
||||
r"""Unique user identifier"""
|
||||
models_llm: NotRequired[Nullable[List[str]]]
|
||||
fallback_models: NotRequired[Nullable[List[str]]]
|
||||
r"""Order of models to fallback to for this request"""
|
||||
reasoning_effort: NotRequired[Nullable[ChatCompletionCreateParamsReasoningEffort]]
|
||||
r"""Reasoning effort"""
|
||||
@@ -1030,7 +985,7 @@ class ChatCompletionCreateParams(BaseModel):
|
||||
user: Optional[str] = None
|
||||
r"""Unique user identifier"""
|
||||
|
||||
models_llm: Annotated[
|
||||
fallback_models: Annotated[
|
||||
OptionalNullable[List[str]], pydantic.Field(alias="models")
|
||||
] = UNSET
|
||||
r"""Order of models to fallback to for this request"""
|
||||
@@ -1069,7 +1024,7 @@ class ChatCompletionCreateParams(BaseModel):
|
||||
"tools",
|
||||
"top_p",
|
||||
"user",
|
||||
"models_llm",
|
||||
"fallback_models",
|
||||
"reasoning_effort",
|
||||
"provider",
|
||||
"plugins",
|
||||
@@ -1089,7 +1044,7 @@ class ChatCompletionCreateParams(BaseModel):
|
||||
"stream_options",
|
||||
"temperature",
|
||||
"top_p",
|
||||
"models_llm",
|
||||
"fallback_models",
|
||||
"reasoning_effort",
|
||||
"provider",
|
||||
]
|
||||
|
||||
@@ -1,34 +1,41 @@
|
||||
"""Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT."""
|
||||
|
||||
from __future__ import annotations
|
||||
from openrouter.types import BaseModel, Nullable, UNSET_SENTINEL
|
||||
from openrouter.types import (
|
||||
BaseModel,
|
||||
Nullable,
|
||||
OptionalNullable,
|
||||
UNSET,
|
||||
UNSET_SENTINEL,
|
||||
)
|
||||
from pydantic import model_serializer
|
||||
from typing_extensions import TypedDict
|
||||
from typing import Optional
|
||||
from typing_extensions import NotRequired, TypedDict
|
||||
|
||||
|
||||
class ErrorTypedDict(TypedDict):
|
||||
r"""Error object structure"""
|
||||
|
||||
code: Nullable[str]
|
||||
code: Nullable[float]
|
||||
message: str
|
||||
param: Nullable[str]
|
||||
type: str
|
||||
param: NotRequired[Nullable[str]]
|
||||
type: NotRequired[str]
|
||||
|
||||
|
||||
class Error(BaseModel):
|
||||
r"""Error object structure"""
|
||||
|
||||
code: Nullable[str]
|
||||
code: Nullable[float]
|
||||
|
||||
message: str
|
||||
|
||||
param: Nullable[str]
|
||||
param: OptionalNullable[str] = UNSET
|
||||
|
||||
type: str
|
||||
type: Optional[str] = None
|
||||
|
||||
@model_serializer(mode="wrap")
|
||||
def serialize_model(self, handler):
|
||||
optional_fields = []
|
||||
optional_fields = ["param", "type"]
|
||||
nullable_fields = ["code", "param"]
|
||||
null_default_fields = []
|
||||
|
||||
|
||||
@@ -7,7 +7,6 @@ from .chatcompletionmessagetoolcall import (
|
||||
ChatCompletionMessageToolCallTypedDict,
|
||||
)
|
||||
from .reasoningdetail import ReasoningDetail, ReasoningDetailTypedDict
|
||||
from enum import Enum
|
||||
from openrouter.types import (
|
||||
BaseModel,
|
||||
Nullable,
|
||||
@@ -16,12 +15,11 @@ from openrouter.types import (
|
||||
UNSET_SENTINEL,
|
||||
)
|
||||
from pydantic import model_serializer
|
||||
from typing import List, Optional
|
||||
from typing import List, Literal, Optional
|
||||
from typing_extensions import NotRequired, TypedDict
|
||||
|
||||
|
||||
class ChatCompletionMessageRole(str, Enum):
|
||||
ASSISTANT = "assistant"
|
||||
ChatCompletionMessageRole = Literal["assistant"]
|
||||
|
||||
|
||||
class ChatCompletionMessageTypedDict(TypedDict):
|
||||
|
||||
@@ -1,13 +1,12 @@
|
||||
"""Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT."""
|
||||
|
||||
from __future__ import annotations
|
||||
from enum import Enum
|
||||
from openrouter.types import BaseModel
|
||||
from typing import Literal
|
||||
from typing_extensions import TypedDict
|
||||
|
||||
|
||||
class ChatCompletionMessageToolCallType(str, Enum):
|
||||
FUNCTION = "function"
|
||||
ChatCompletionMessageToolCallType = Literal["function"]
|
||||
|
||||
|
||||
class ChatCompletionMessageToolCallFunctionTypedDict(TypedDict):
|
||||
|
||||
@@ -1,13 +1,12 @@
|
||||
"""Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT."""
|
||||
|
||||
from __future__ import annotations
|
||||
from enum import Enum
|
||||
from openrouter.types import BaseModel
|
||||
from typing import Literal
|
||||
from typing_extensions import TypedDict
|
||||
|
||||
|
||||
class ChatCompletionNamedToolChoiceType(str, Enum):
|
||||
FUNCTION = "function"
|
||||
ChatCompletionNamedToolChoiceType = Literal["function"]
|
||||
|
||||
|
||||
class ChatCompletionNamedToolChoiceFunctionTypedDict(TypedDict):
|
||||
|
||||
@@ -5,15 +5,12 @@ from .chatcompletioncontentparttext import (
|
||||
ChatCompletionContentPartText,
|
||||
ChatCompletionContentPartTextTypedDict,
|
||||
)
|
||||
from enum import Enum
|
||||
from openrouter.types import BaseModel
|
||||
from typing import List, Optional, Union
|
||||
from typing import List, Literal, Optional, Union
|
||||
from typing_extensions import NotRequired, TypeAliasType, TypedDict
|
||||
|
||||
|
||||
class ChatCompletionSystemMessageParamRole(str, Enum):
|
||||
SYSTEM = "system"
|
||||
|
||||
ChatCompletionSystemMessageParamRole = Literal["system"]
|
||||
|
||||
ChatCompletionSystemMessageParamContentTypedDict = TypeAliasType(
|
||||
"ChatCompletionSystemMessageParamContentTypedDict",
|
||||
|
||||
@@ -1,7 +1,6 @@
|
||||
"""Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT."""
|
||||
|
||||
from __future__ import annotations
|
||||
from enum import Enum
|
||||
from openrouter.types import (
|
||||
BaseModel,
|
||||
Nullable,
|
||||
@@ -10,12 +9,11 @@ from openrouter.types import (
|
||||
UNSET_SENTINEL,
|
||||
)
|
||||
from pydantic import model_serializer
|
||||
from typing import Optional
|
||||
from typing import Literal, Optional
|
||||
from typing_extensions import NotRequired, TypedDict
|
||||
|
||||
|
||||
class ChatCompletionToolType(str, Enum):
|
||||
FUNCTION = "function"
|
||||
ChatCompletionToolType = Literal["function"]
|
||||
|
||||
|
||||
class ParametersTypedDict(TypedDict):
|
||||
|
||||
@@ -5,22 +5,15 @@ from .chatcompletionnamedtoolchoice import (
|
||||
ChatCompletionNamedToolChoice,
|
||||
ChatCompletionNamedToolChoiceTypedDict,
|
||||
)
|
||||
from enum import Enum
|
||||
from typing import Union
|
||||
from typing import Literal, Union
|
||||
from typing_extensions import TypeAliasType
|
||||
|
||||
|
||||
class ChatCompletionToolChoiceOptionRequired(str, Enum):
|
||||
REQUIRED = "required"
|
||||
ChatCompletionToolChoiceOptionRequired = Literal["required"]
|
||||
|
||||
ChatCompletionToolChoiceOptionAuto = Literal["auto"]
|
||||
|
||||
class ChatCompletionToolChoiceOptionAuto(str, Enum):
|
||||
AUTO = "auto"
|
||||
|
||||
|
||||
class ChatCompletionToolChoiceOptionNone(str, Enum):
|
||||
NONE = "none"
|
||||
|
||||
ChatCompletionToolChoiceOptionNone = Literal["none"]
|
||||
|
||||
ChatCompletionToolChoiceOptionTypedDict = TypeAliasType(
|
||||
"ChatCompletionToolChoiceOptionTypedDict",
|
||||
|
||||
@@ -5,15 +5,12 @@ from .chatcompletioncontentpart import (
|
||||
ChatCompletionContentPart,
|
||||
ChatCompletionContentPartTypedDict,
|
||||
)
|
||||
from enum import Enum
|
||||
from openrouter.types import BaseModel
|
||||
from typing import List, Union
|
||||
from typing import List, Literal, Union
|
||||
from typing_extensions import TypeAliasType, TypedDict
|
||||
|
||||
|
||||
class ChatCompletionToolMessageParamRole(str, Enum):
|
||||
TOOL = "tool"
|
||||
|
||||
ChatCompletionToolMessageParamRole = Literal["tool"]
|
||||
|
||||
ChatCompletionToolMessageParamContentTypedDict = TypeAliasType(
|
||||
"ChatCompletionToolMessageParamContentTypedDict",
|
||||
|
||||
@@ -5,15 +5,12 @@ from .chatcompletioncontentpart import (
|
||||
ChatCompletionContentPart,
|
||||
ChatCompletionContentPartTypedDict,
|
||||
)
|
||||
from enum import Enum
|
||||
from openrouter.types import BaseModel
|
||||
from typing import List, Optional, Union
|
||||
from typing import List, Literal, Optional, Union
|
||||
from typing_extensions import NotRequired, TypeAliasType, TypedDict
|
||||
|
||||
|
||||
class ChatCompletionUserMessageParamRole(str, Enum):
|
||||
USER = "user"
|
||||
|
||||
ChatCompletionUserMessageParamRole = Literal["user"]
|
||||
|
||||
ChatCompletionUserMessageParamContentTypedDict = TypeAliasType(
|
||||
"ChatCompletionUserMessageParamContentTypedDict",
|
||||
|
||||
@@ -14,7 +14,6 @@ from .responseformatjsonschemaschema import (
|
||||
ResponseFormatJSONSchemaSchema,
|
||||
ResponseFormatJSONSchemaSchemaTypedDict,
|
||||
)
|
||||
from enum import Enum
|
||||
from openrouter.types import (
|
||||
BaseModel,
|
||||
Nullable,
|
||||
@@ -24,17 +23,12 @@ from openrouter.types import (
|
||||
)
|
||||
import pydantic
|
||||
from pydantic import model_serializer
|
||||
from typing import Any, Dict, List, Optional, Union
|
||||
from typing import Any, Dict, List, Literal, Optional, Union
|
||||
from typing_extensions import Annotated, NotRequired, TypeAliasType, TypedDict
|
||||
|
||||
|
||||
class ChatStreamCompletionCreateParamsEffort(str, Enum):
|
||||
r"""OpenAI-style reasoning effort setting"""
|
||||
|
||||
HIGH = "high"
|
||||
MEDIUM = "medium"
|
||||
LOW = "low"
|
||||
MINIMAL = "minimal"
|
||||
ChatStreamCompletionCreateParamsEffort = Literal["high", "medium", "low", "minimal"]
|
||||
r"""OpenAI-style reasoning effort setting"""
|
||||
|
||||
|
||||
class ChatStreamCompletionCreateParamsReasoningTypedDict(TypedDict):
|
||||
@@ -94,8 +88,7 @@ class ChatStreamCompletionCreateParamsReasoning(BaseModel):
|
||||
return m
|
||||
|
||||
|
||||
class ChatStreamCompletionCreateParamsTypePython(str, Enum):
|
||||
PYTHON = "python"
|
||||
ChatStreamCompletionCreateParamsTypePython = Literal["python"]
|
||||
|
||||
|
||||
class ChatStreamCompletionCreateParamsResponseFormatPythonTypedDict(TypedDict):
|
||||
@@ -110,8 +103,7 @@ class ChatStreamCompletionCreateParamsResponseFormatPython(BaseModel):
|
||||
type: ChatStreamCompletionCreateParamsTypePython
|
||||
|
||||
|
||||
class ChatStreamCompletionCreateParamsTypeGrammar(str, Enum):
|
||||
GRAMMAR = "grammar"
|
||||
ChatStreamCompletionCreateParamsTypeGrammar = Literal["grammar"]
|
||||
|
||||
|
||||
class ChatStreamCompletionCreateParamsResponseFormatGrammarTypedDict(TypedDict):
|
||||
@@ -131,8 +123,7 @@ class ChatStreamCompletionCreateParamsResponseFormatGrammar(BaseModel):
|
||||
r"""Custom grammar for text generation"""
|
||||
|
||||
|
||||
class ChatStreamCompletionCreateParamsTypeJSONSchema(str, Enum):
|
||||
JSON_SCHEMA = "json_schema"
|
||||
ChatStreamCompletionCreateParamsTypeJSONSchema = Literal["json_schema"]
|
||||
|
||||
|
||||
class ChatStreamCompletionCreateParamsJSONSchemaTypedDict(TypedDict):
|
||||
@@ -207,8 +198,7 @@ class ChatStreamCompletionCreateParamsResponseFormatJSONSchema(BaseModel):
|
||||
json_schema: ChatStreamCompletionCreateParamsJSONSchema
|
||||
|
||||
|
||||
class ChatStreamCompletionCreateParamsTypeJSONObject(str, Enum):
|
||||
JSON_OBJECT = "json_object"
|
||||
ChatStreamCompletionCreateParamsTypeJSONObject = Literal["json_object"]
|
||||
|
||||
|
||||
class ChatStreamCompletionCreateParamsResponseFormatJSONObjectTypedDict(TypedDict):
|
||||
@@ -223,8 +213,7 @@ class ChatStreamCompletionCreateParamsResponseFormatJSONObject(BaseModel):
|
||||
type: ChatStreamCompletionCreateParamsTypeJSONObject
|
||||
|
||||
|
||||
class ChatStreamCompletionCreateParamsTypeText(str, Enum):
|
||||
TEXT = "text"
|
||||
ChatStreamCompletionCreateParamsTypeText = Literal["text"]
|
||||
|
||||
|
||||
class ChatStreamCompletionCreateParamsResponseFormatTextTypedDict(TypedDict):
|
||||
@@ -291,106 +280,98 @@ class ChatStreamCompletionCreateParamsStreamOptions(BaseModel):
|
||||
r"""Include usage information in streaming response"""
|
||||
|
||||
|
||||
class ChatStreamCompletionCreateParamsReasoningEffort(str, Enum):
|
||||
r"""Reasoning effort"""
|
||||
ChatStreamCompletionCreateParamsReasoningEffort = Literal[
|
||||
"high", "medium", "low", "minimal"
|
||||
]
|
||||
r"""Reasoning effort"""
|
||||
|
||||
HIGH = "high"
|
||||
MEDIUM = "medium"
|
||||
LOW = "low"
|
||||
MINIMAL = "minimal"
|
||||
ChatStreamCompletionCreateParamsDataCollection = Literal["deny", "allow"]
|
||||
r"""Data collection setting. If no available model provider meets the requirement, your request will return an error.
|
||||
- allow: (default) allow providers which store user data non-transiently and may train on it
|
||||
- deny: use only providers which do not collect user data.
|
||||
|
||||
"""
|
||||
|
||||
class ChatStreamCompletionCreateParamsDataCollection(str, Enum):
|
||||
r"""Data collection setting. If no available model provider meets the requirement, your request will return an error.
|
||||
- allow: (default) allow providers which store user data non-transiently and may train on it
|
||||
- deny: use only providers which do not collect user data.
|
||||
|
||||
"""
|
||||
|
||||
DENY = "deny"
|
||||
ALLOW = "allow"
|
||||
|
||||
|
||||
class ChatStreamCompletionCreateParamsOrderEnum(str, Enum):
|
||||
ANY_SCALE = "AnyScale"
|
||||
CENT_ML = "Cent-ML"
|
||||
HUGGING_FACE = "HuggingFace"
|
||||
HYPERBOLIC_2 = "Hyperbolic 2"
|
||||
LEPTON = "Lepton"
|
||||
LYNN_2 = "Lynn 2"
|
||||
LYNN = "Lynn"
|
||||
MANCER = "Mancer"
|
||||
MODAL = "Modal"
|
||||
OCTO_AI = "OctoAI"
|
||||
RECURSAL = "Recursal"
|
||||
REFLECTION = "Reflection"
|
||||
REPLICATE = "Replicate"
|
||||
SAMBA_NOVA_2 = "SambaNova 2"
|
||||
SF_COMPUTE = "SF Compute"
|
||||
TOGETHER_2 = "Together 2"
|
||||
ONE_DOT_AI = "01.AI"
|
||||
AI21 = "AI21"
|
||||
AION_LABS = "AionLabs"
|
||||
ALIBABA = "Alibaba"
|
||||
AMAZON_BEDROCK = "Amazon Bedrock"
|
||||
ANTHROPIC = "Anthropic"
|
||||
ATLAS_CLOUD = "AtlasCloud"
|
||||
ATOMA = "Atoma"
|
||||
AVIAN = "Avian"
|
||||
AZURE = "Azure"
|
||||
BASE_TEN = "BaseTen"
|
||||
CEREBRAS = "Cerebras"
|
||||
CHUTES = "Chutes"
|
||||
CLOUDFLARE = "Cloudflare"
|
||||
COHERE = "Cohere"
|
||||
CROF_AI = "CrofAI"
|
||||
CRUSOE = "Crusoe"
|
||||
DEEP_INFRA = "DeepInfra"
|
||||
DEEP_SEEK = "DeepSeek"
|
||||
ENFER = "Enfer"
|
||||
FEATHERLESS = "Featherless"
|
||||
FIREWORKS = "Fireworks"
|
||||
FRIENDLI = "Friendli"
|
||||
GMI_CLOUD = "GMICloud"
|
||||
GOOGLE = "Google"
|
||||
GOOGLE_AI_STUDIO = "Google AI Studio"
|
||||
GROQ = "Groq"
|
||||
HYPERBOLIC = "Hyperbolic"
|
||||
INCEPTION = "Inception"
|
||||
INFERENCE_NET = "InferenceNet"
|
||||
INFERMATIC = "Infermatic"
|
||||
INFLECTION = "Inflection"
|
||||
INO_CLOUD = "InoCloud"
|
||||
KLUSTER = "Kluster"
|
||||
LAMBDA = "Lambda"
|
||||
LIQUID = "Liquid"
|
||||
MANCER_2 = "Mancer 2"
|
||||
META = "Meta"
|
||||
MINIMAX = "Minimax"
|
||||
MISTRAL = "Mistral"
|
||||
MOONSHOT_AI = "Moonshot AI"
|
||||
MORPH = "Morph"
|
||||
N_COMPASS = "NCompass"
|
||||
NEBIUS = "Nebius"
|
||||
NEXT_BIT = "NextBit"
|
||||
NINETEEN = "Nineteen"
|
||||
NOVITA = "Novita"
|
||||
OPEN_AI = "OpenAI"
|
||||
OPEN_INFERENCE = "OpenInference"
|
||||
PARASAIL = "Parasail"
|
||||
PERPLEXITY = "Perplexity"
|
||||
PHALA = "Phala"
|
||||
SAMBA_NOVA = "SambaNova"
|
||||
STEALTH = "Stealth"
|
||||
SWITCHPOINT = "Switchpoint"
|
||||
TARGON = "Targon"
|
||||
TOGETHER = "Together"
|
||||
UBICLOUD = "Ubicloud"
|
||||
VENICE = "Venice"
|
||||
WAND_B = "WandB"
|
||||
X_AI = "xAI"
|
||||
Z_AI = "Z.AI"
|
||||
|
||||
ChatStreamCompletionCreateParamsOrderEnum = Literal[
|
||||
"AnyScale",
|
||||
"Cent-ML",
|
||||
"HuggingFace",
|
||||
"Hyperbolic 2",
|
||||
"Lepton",
|
||||
"Lynn 2",
|
||||
"Lynn",
|
||||
"Mancer",
|
||||
"Modal",
|
||||
"OctoAI",
|
||||
"Recursal",
|
||||
"Reflection",
|
||||
"Replicate",
|
||||
"SambaNova 2",
|
||||
"SF Compute",
|
||||
"Together 2",
|
||||
"01.AI",
|
||||
"AI21",
|
||||
"AionLabs",
|
||||
"Alibaba",
|
||||
"Amazon Bedrock",
|
||||
"Anthropic",
|
||||
"AtlasCloud",
|
||||
"Atoma",
|
||||
"Avian",
|
||||
"Azure",
|
||||
"BaseTen",
|
||||
"Cerebras",
|
||||
"Chutes",
|
||||
"Cloudflare",
|
||||
"Cohere",
|
||||
"CrofAI",
|
||||
"Crusoe",
|
||||
"DeepInfra",
|
||||
"DeepSeek",
|
||||
"Enfer",
|
||||
"Featherless",
|
||||
"Fireworks",
|
||||
"Friendli",
|
||||
"GMICloud",
|
||||
"Google",
|
||||
"Google AI Studio",
|
||||
"Groq",
|
||||
"Hyperbolic",
|
||||
"Inception",
|
||||
"InferenceNet",
|
||||
"Infermatic",
|
||||
"Inflection",
|
||||
"InoCloud",
|
||||
"Kluster",
|
||||
"Lambda",
|
||||
"Liquid",
|
||||
"Mancer 2",
|
||||
"Meta",
|
||||
"Minimax",
|
||||
"Mistral",
|
||||
"Moonshot AI",
|
||||
"Morph",
|
||||
"NCompass",
|
||||
"Nebius",
|
||||
"NextBit",
|
||||
"Nineteen",
|
||||
"Novita",
|
||||
"OpenAI",
|
||||
"OpenInference",
|
||||
"Parasail",
|
||||
"Perplexity",
|
||||
"Phala",
|
||||
"SambaNova",
|
||||
"Stealth",
|
||||
"Switchpoint",
|
||||
"Targon",
|
||||
"Together",
|
||||
"Ubicloud",
|
||||
"Venice",
|
||||
"WandB",
|
||||
"xAI",
|
||||
"Z.AI",
|
||||
]
|
||||
|
||||
ChatStreamCompletionCreateParamsOrderUnionTypedDict = TypeAliasType(
|
||||
"ChatStreamCompletionCreateParamsOrderUnionTypedDict",
|
||||
@@ -404,86 +385,86 @@ ChatStreamCompletionCreateParamsOrderUnion = TypeAliasType(
|
||||
)
|
||||
|
||||
|
||||
class ChatStreamCompletionCreateParamsOnlyEnum(str, Enum):
|
||||
ANY_SCALE = "AnyScale"
|
||||
CENT_ML = "Cent-ML"
|
||||
HUGGING_FACE = "HuggingFace"
|
||||
HYPERBOLIC_2 = "Hyperbolic 2"
|
||||
LEPTON = "Lepton"
|
||||
LYNN_2 = "Lynn 2"
|
||||
LYNN = "Lynn"
|
||||
MANCER = "Mancer"
|
||||
MODAL = "Modal"
|
||||
OCTO_AI = "OctoAI"
|
||||
RECURSAL = "Recursal"
|
||||
REFLECTION = "Reflection"
|
||||
REPLICATE = "Replicate"
|
||||
SAMBA_NOVA_2 = "SambaNova 2"
|
||||
SF_COMPUTE = "SF Compute"
|
||||
TOGETHER_2 = "Together 2"
|
||||
ONE_DOT_AI = "01.AI"
|
||||
AI21 = "AI21"
|
||||
AION_LABS = "AionLabs"
|
||||
ALIBABA = "Alibaba"
|
||||
AMAZON_BEDROCK = "Amazon Bedrock"
|
||||
ANTHROPIC = "Anthropic"
|
||||
ATLAS_CLOUD = "AtlasCloud"
|
||||
ATOMA = "Atoma"
|
||||
AVIAN = "Avian"
|
||||
AZURE = "Azure"
|
||||
BASE_TEN = "BaseTen"
|
||||
CEREBRAS = "Cerebras"
|
||||
CHUTES = "Chutes"
|
||||
CLOUDFLARE = "Cloudflare"
|
||||
COHERE = "Cohere"
|
||||
CROF_AI = "CrofAI"
|
||||
CRUSOE = "Crusoe"
|
||||
DEEP_INFRA = "DeepInfra"
|
||||
DEEP_SEEK = "DeepSeek"
|
||||
ENFER = "Enfer"
|
||||
FEATHERLESS = "Featherless"
|
||||
FIREWORKS = "Fireworks"
|
||||
FRIENDLI = "Friendli"
|
||||
GMI_CLOUD = "GMICloud"
|
||||
GOOGLE = "Google"
|
||||
GOOGLE_AI_STUDIO = "Google AI Studio"
|
||||
GROQ = "Groq"
|
||||
HYPERBOLIC = "Hyperbolic"
|
||||
INCEPTION = "Inception"
|
||||
INFERENCE_NET = "InferenceNet"
|
||||
INFERMATIC = "Infermatic"
|
||||
INFLECTION = "Inflection"
|
||||
INO_CLOUD = "InoCloud"
|
||||
KLUSTER = "Kluster"
|
||||
LAMBDA = "Lambda"
|
||||
LIQUID = "Liquid"
|
||||
MANCER_2 = "Mancer 2"
|
||||
META = "Meta"
|
||||
MINIMAX = "Minimax"
|
||||
MISTRAL = "Mistral"
|
||||
MOONSHOT_AI = "Moonshot AI"
|
||||
MORPH = "Morph"
|
||||
N_COMPASS = "NCompass"
|
||||
NEBIUS = "Nebius"
|
||||
NEXT_BIT = "NextBit"
|
||||
NINETEEN = "Nineteen"
|
||||
NOVITA = "Novita"
|
||||
OPEN_AI = "OpenAI"
|
||||
OPEN_INFERENCE = "OpenInference"
|
||||
PARASAIL = "Parasail"
|
||||
PERPLEXITY = "Perplexity"
|
||||
PHALA = "Phala"
|
||||
SAMBA_NOVA = "SambaNova"
|
||||
STEALTH = "Stealth"
|
||||
SWITCHPOINT = "Switchpoint"
|
||||
TARGON = "Targon"
|
||||
TOGETHER = "Together"
|
||||
UBICLOUD = "Ubicloud"
|
||||
VENICE = "Venice"
|
||||
WAND_B = "WandB"
|
||||
X_AI = "xAI"
|
||||
Z_AI = "Z.AI"
|
||||
|
||||
ChatStreamCompletionCreateParamsOnlyEnum = Literal[
|
||||
"AnyScale",
|
||||
"Cent-ML",
|
||||
"HuggingFace",
|
||||
"Hyperbolic 2",
|
||||
"Lepton",
|
||||
"Lynn 2",
|
||||
"Lynn",
|
||||
"Mancer",
|
||||
"Modal",
|
||||
"OctoAI",
|
||||
"Recursal",
|
||||
"Reflection",
|
||||
"Replicate",
|
||||
"SambaNova 2",
|
||||
"SF Compute",
|
||||
"Together 2",
|
||||
"01.AI",
|
||||
"AI21",
|
||||
"AionLabs",
|
||||
"Alibaba",
|
||||
"Amazon Bedrock",
|
||||
"Anthropic",
|
||||
"AtlasCloud",
|
||||
"Atoma",
|
||||
"Avian",
|
||||
"Azure",
|
||||
"BaseTen",
|
||||
"Cerebras",
|
||||
"Chutes",
|
||||
"Cloudflare",
|
||||
"Cohere",
|
||||
"CrofAI",
|
||||
"Crusoe",
|
||||
"DeepInfra",
|
||||
"DeepSeek",
|
||||
"Enfer",
|
||||
"Featherless",
|
||||
"Fireworks",
|
||||
"Friendli",
|
||||
"GMICloud",
|
||||
"Google",
|
||||
"Google AI Studio",
|
||||
"Groq",
|
||||
"Hyperbolic",
|
||||
"Inception",
|
||||
"InferenceNet",
|
||||
"Infermatic",
|
||||
"Inflection",
|
||||
"InoCloud",
|
||||
"Kluster",
|
||||
"Lambda",
|
||||
"Liquid",
|
||||
"Mancer 2",
|
||||
"Meta",
|
||||
"Minimax",
|
||||
"Mistral",
|
||||
"Moonshot AI",
|
||||
"Morph",
|
||||
"NCompass",
|
||||
"Nebius",
|
||||
"NextBit",
|
||||
"Nineteen",
|
||||
"Novita",
|
||||
"OpenAI",
|
||||
"OpenInference",
|
||||
"Parasail",
|
||||
"Perplexity",
|
||||
"Phala",
|
||||
"SambaNova",
|
||||
"Stealth",
|
||||
"Switchpoint",
|
||||
"Targon",
|
||||
"Together",
|
||||
"Ubicloud",
|
||||
"Venice",
|
||||
"WandB",
|
||||
"xAI",
|
||||
"Z.AI",
|
||||
]
|
||||
|
||||
ChatStreamCompletionCreateParamsOnlyUnionTypedDict = TypeAliasType(
|
||||
"ChatStreamCompletionCreateParamsOnlyUnionTypedDict",
|
||||
@@ -497,86 +478,86 @@ ChatStreamCompletionCreateParamsOnlyUnion = TypeAliasType(
|
||||
)
|
||||
|
||||
|
||||
class ChatStreamCompletionCreateParamsIgnoreEnum(str, Enum):
|
||||
ANY_SCALE = "AnyScale"
|
||||
CENT_ML = "Cent-ML"
|
||||
HUGGING_FACE = "HuggingFace"
|
||||
HYPERBOLIC_2 = "Hyperbolic 2"
|
||||
LEPTON = "Lepton"
|
||||
LYNN_2 = "Lynn 2"
|
||||
LYNN = "Lynn"
|
||||
MANCER = "Mancer"
|
||||
MODAL = "Modal"
|
||||
OCTO_AI = "OctoAI"
|
||||
RECURSAL = "Recursal"
|
||||
REFLECTION = "Reflection"
|
||||
REPLICATE = "Replicate"
|
||||
SAMBA_NOVA_2 = "SambaNova 2"
|
||||
SF_COMPUTE = "SF Compute"
|
||||
TOGETHER_2 = "Together 2"
|
||||
ONE_DOT_AI = "01.AI"
|
||||
AI21 = "AI21"
|
||||
AION_LABS = "AionLabs"
|
||||
ALIBABA = "Alibaba"
|
||||
AMAZON_BEDROCK = "Amazon Bedrock"
|
||||
ANTHROPIC = "Anthropic"
|
||||
ATLAS_CLOUD = "AtlasCloud"
|
||||
ATOMA = "Atoma"
|
||||
AVIAN = "Avian"
|
||||
AZURE = "Azure"
|
||||
BASE_TEN = "BaseTen"
|
||||
CEREBRAS = "Cerebras"
|
||||
CHUTES = "Chutes"
|
||||
CLOUDFLARE = "Cloudflare"
|
||||
COHERE = "Cohere"
|
||||
CROF_AI = "CrofAI"
|
||||
CRUSOE = "Crusoe"
|
||||
DEEP_INFRA = "DeepInfra"
|
||||
DEEP_SEEK = "DeepSeek"
|
||||
ENFER = "Enfer"
|
||||
FEATHERLESS = "Featherless"
|
||||
FIREWORKS = "Fireworks"
|
||||
FRIENDLI = "Friendli"
|
||||
GMI_CLOUD = "GMICloud"
|
||||
GOOGLE = "Google"
|
||||
GOOGLE_AI_STUDIO = "Google AI Studio"
|
||||
GROQ = "Groq"
|
||||
HYPERBOLIC = "Hyperbolic"
|
||||
INCEPTION = "Inception"
|
||||
INFERENCE_NET = "InferenceNet"
|
||||
INFERMATIC = "Infermatic"
|
||||
INFLECTION = "Inflection"
|
||||
INO_CLOUD = "InoCloud"
|
||||
KLUSTER = "Kluster"
|
||||
LAMBDA = "Lambda"
|
||||
LIQUID = "Liquid"
|
||||
MANCER_2 = "Mancer 2"
|
||||
META = "Meta"
|
||||
MINIMAX = "Minimax"
|
||||
MISTRAL = "Mistral"
|
||||
MOONSHOT_AI = "Moonshot AI"
|
||||
MORPH = "Morph"
|
||||
N_COMPASS = "NCompass"
|
||||
NEBIUS = "Nebius"
|
||||
NEXT_BIT = "NextBit"
|
||||
NINETEEN = "Nineteen"
|
||||
NOVITA = "Novita"
|
||||
OPEN_AI = "OpenAI"
|
||||
OPEN_INFERENCE = "OpenInference"
|
||||
PARASAIL = "Parasail"
|
||||
PERPLEXITY = "Perplexity"
|
||||
PHALA = "Phala"
|
||||
SAMBA_NOVA = "SambaNova"
|
||||
STEALTH = "Stealth"
|
||||
SWITCHPOINT = "Switchpoint"
|
||||
TARGON = "Targon"
|
||||
TOGETHER = "Together"
|
||||
UBICLOUD = "Ubicloud"
|
||||
VENICE = "Venice"
|
||||
WAND_B = "WandB"
|
||||
X_AI = "xAI"
|
||||
Z_AI = "Z.AI"
|
||||
|
||||
ChatStreamCompletionCreateParamsIgnoreEnum = Literal[
|
||||
"AnyScale",
|
||||
"Cent-ML",
|
||||
"HuggingFace",
|
||||
"Hyperbolic 2",
|
||||
"Lepton",
|
||||
"Lynn 2",
|
||||
"Lynn",
|
||||
"Mancer",
|
||||
"Modal",
|
||||
"OctoAI",
|
||||
"Recursal",
|
||||
"Reflection",
|
||||
"Replicate",
|
||||
"SambaNova 2",
|
||||
"SF Compute",
|
||||
"Together 2",
|
||||
"01.AI",
|
||||
"AI21",
|
||||
"AionLabs",
|
||||
"Alibaba",
|
||||
"Amazon Bedrock",
|
||||
"Anthropic",
|
||||
"AtlasCloud",
|
||||
"Atoma",
|
||||
"Avian",
|
||||
"Azure",
|
||||
"BaseTen",
|
||||
"Cerebras",
|
||||
"Chutes",
|
||||
"Cloudflare",
|
||||
"Cohere",
|
||||
"CrofAI",
|
||||
"Crusoe",
|
||||
"DeepInfra",
|
||||
"DeepSeek",
|
||||
"Enfer",
|
||||
"Featherless",
|
||||
"Fireworks",
|
||||
"Friendli",
|
||||
"GMICloud",
|
||||
"Google",
|
||||
"Google AI Studio",
|
||||
"Groq",
|
||||
"Hyperbolic",
|
||||
"Inception",
|
||||
"InferenceNet",
|
||||
"Infermatic",
|
||||
"Inflection",
|
||||
"InoCloud",
|
||||
"Kluster",
|
||||
"Lambda",
|
||||
"Liquid",
|
||||
"Mancer 2",
|
||||
"Meta",
|
||||
"Minimax",
|
||||
"Mistral",
|
||||
"Moonshot AI",
|
||||
"Morph",
|
||||
"NCompass",
|
||||
"Nebius",
|
||||
"NextBit",
|
||||
"Nineteen",
|
||||
"Novita",
|
||||
"OpenAI",
|
||||
"OpenInference",
|
||||
"Parasail",
|
||||
"Perplexity",
|
||||
"Phala",
|
||||
"SambaNova",
|
||||
"Stealth",
|
||||
"Switchpoint",
|
||||
"Targon",
|
||||
"Together",
|
||||
"Ubicloud",
|
||||
"Venice",
|
||||
"WandB",
|
||||
"xAI",
|
||||
"Z.AI",
|
||||
]
|
||||
|
||||
ChatStreamCompletionCreateParamsIgnoreUnionTypedDict = TypeAliasType(
|
||||
"ChatStreamCompletionCreateParamsIgnoreUnionTypedDict",
|
||||
@@ -590,25 +571,12 @@ ChatStreamCompletionCreateParamsIgnoreUnion = TypeAliasType(
|
||||
)
|
||||
|
||||
|
||||
class ChatStreamCompletionCreateParamsQuantization(str, Enum):
|
||||
INT4 = "int4"
|
||||
INT8 = "int8"
|
||||
FP4 = "fp4"
|
||||
FP6 = "fp6"
|
||||
FP8 = "fp8"
|
||||
FP16 = "fp16"
|
||||
BF16 = "bf16"
|
||||
FP32 = "fp32"
|
||||
UNKNOWN = "unknown"
|
||||
|
||||
|
||||
class ChatStreamCompletionCreateParamsSort(str, Enum):
|
||||
r"""The sorting strategy to use for this request, if \"order\" is not specified. When set, no load balancing is performed."""
|
||||
|
||||
PRICE = "price"
|
||||
THROUGHPUT = "throughput"
|
||||
LATENCY = "latency"
|
||||
ChatStreamCompletionCreateParamsQuantization = Literal[
|
||||
"int4", "int8", "fp4", "fp6", "fp8", "fp16", "bf16", "fp32", "unknown"
|
||||
]
|
||||
|
||||
ChatStreamCompletionCreateParamsSort = Literal["price", "throughput", "latency"]
|
||||
r"""The sorting strategy to use for this request, if \"order\" is not specified. When set, no load balancing is performed."""
|
||||
|
||||
ChatStreamCompletionCreateParamsPromptTypedDict = TypeAliasType(
|
||||
"ChatStreamCompletionCreateParamsPromptTypedDict", Union[float, str, Any]
|
||||
@@ -817,14 +785,9 @@ class ChatStreamCompletionCreateParamsProvider(BaseModel):
|
||||
return m
|
||||
|
||||
|
||||
class ChatStreamCompletionCreateParamsIDFileParser(str, Enum):
|
||||
FILE_PARSER = "file-parser"
|
||||
ChatStreamCompletionCreateParamsIDFileParser = Literal["file-parser"]
|
||||
|
||||
|
||||
class ChatStreamCompletionCreateParamsPdfEngine(str, Enum):
|
||||
MISTRAL_OCR = "mistral-ocr"
|
||||
PDF_TEXT = "pdf-text"
|
||||
NATIVE = "native"
|
||||
ChatStreamCompletionCreateParamsPdfEngine = Literal["mistral-ocr", "pdf-text", "native"]
|
||||
|
||||
|
||||
class ChatStreamCompletionCreateParamsPdfTypedDict(TypedDict):
|
||||
@@ -849,8 +812,7 @@ class ChatStreamCompletionCreateParamsPluginFileParser(BaseModel):
|
||||
pdf: Optional[ChatStreamCompletionCreateParamsPdf] = None
|
||||
|
||||
|
||||
class ChatStreamCompletionCreateParamsIDChainOfThought(str, Enum):
|
||||
CHAIN_OF_THOUGHT = "chain-of-thought"
|
||||
ChatStreamCompletionCreateParamsIDChainOfThought = Literal["chain-of-thought"]
|
||||
|
||||
|
||||
class ChatStreamCompletionCreateParamsPluginChainOfThoughtTypedDict(TypedDict):
|
||||
@@ -861,13 +823,9 @@ class ChatStreamCompletionCreateParamsPluginChainOfThought(BaseModel):
|
||||
id: ChatStreamCompletionCreateParamsIDChainOfThought
|
||||
|
||||
|
||||
class ChatStreamCompletionCreateParamsIDWeb(str, Enum):
|
||||
WEB = "web"
|
||||
ChatStreamCompletionCreateParamsIDWeb = Literal["web"]
|
||||
|
||||
|
||||
class ChatStreamCompletionCreateParamsEngine(str, Enum):
|
||||
NATIVE = "native"
|
||||
EXA = "exa"
|
||||
ChatStreamCompletionCreateParamsEngine = Literal["native", "exa"]
|
||||
|
||||
|
||||
class ChatStreamCompletionCreateParamsPluginWebTypedDict(TypedDict):
|
||||
@@ -887,8 +845,7 @@ class ChatStreamCompletionCreateParamsPluginWeb(BaseModel):
|
||||
engine: Optional[ChatStreamCompletionCreateParamsEngine] = None
|
||||
|
||||
|
||||
class ChatStreamCompletionCreateParamsIDModeration(str, Enum):
|
||||
MODERATION = "moderation"
|
||||
ChatStreamCompletionCreateParamsIDModeration = Literal["moderation"]
|
||||
|
||||
|
||||
class ChatStreamCompletionCreateParamsPluginModerationTypedDict(TypedDict):
|
||||
@@ -969,7 +926,7 @@ class ChatStreamCompletionCreateParamsTypedDict(TypedDict):
|
||||
r"""Nucleus sampling parameter (0-1)"""
|
||||
user: NotRequired[str]
|
||||
r"""Unique user identifier"""
|
||||
models_llm: NotRequired[Nullable[List[str]]]
|
||||
fallback_models: NotRequired[Nullable[List[str]]]
|
||||
r"""Order of models to fallback to for this request"""
|
||||
reasoning_effort: NotRequired[
|
||||
Nullable[ChatStreamCompletionCreateParamsReasoningEffort]
|
||||
@@ -1050,7 +1007,7 @@ class ChatStreamCompletionCreateParams(BaseModel):
|
||||
user: Optional[str] = None
|
||||
r"""Unique user identifier"""
|
||||
|
||||
models_llm: Annotated[
|
||||
fallback_models: Annotated[
|
||||
OptionalNullable[List[str]], pydantic.Field(alias="models")
|
||||
] = UNSET
|
||||
r"""Order of models to fallback to for this request"""
|
||||
@@ -1089,7 +1046,7 @@ class ChatStreamCompletionCreateParams(BaseModel):
|
||||
"tools",
|
||||
"top_p",
|
||||
"user",
|
||||
"models_llm",
|
||||
"fallback_models",
|
||||
"reasoning_effort",
|
||||
"provider",
|
||||
"plugins",
|
||||
@@ -1108,7 +1065,7 @@ class ChatStreamCompletionCreateParams(BaseModel):
|
||||
"stream_options",
|
||||
"temperature",
|
||||
"top_p",
|
||||
"models_llm",
|
||||
"fallback_models",
|
||||
"reasoning_effort",
|
||||
"provider",
|
||||
]
|
||||
|
||||
@@ -1,18 +1,14 @@
|
||||
"""Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT."""
|
||||
|
||||
from __future__ import annotations
|
||||
from enum import Enum
|
||||
from openrouter.types import BaseModel
|
||||
from typing import List, Optional, Union
|
||||
from typing import List, Literal, Optional, Union
|
||||
from typing_extensions import NotRequired, TypeAliasType, TypedDict
|
||||
|
||||
|
||||
class TypeFile(str, Enum):
|
||||
FILE = "file"
|
||||
TypeFile = Literal["file"]
|
||||
|
||||
|
||||
class ContentTypeImageURL(str, Enum):
|
||||
IMAGE_URL = "image_url"
|
||||
ContentTypeImageURL = Literal["image_url"]
|
||||
|
||||
|
||||
class FileAnnotationDetailImageURLTypedDict(TypedDict):
|
||||
@@ -34,8 +30,7 @@ class ContentImageURL(BaseModel):
|
||||
image_url: FileAnnotationDetailImageURL
|
||||
|
||||
|
||||
class ContentTypeText(str, Enum):
|
||||
TEXT = "text"
|
||||
ContentTypeText = Literal["text"]
|
||||
|
||||
|
||||
class ContentTextTypedDict(TypedDict):
|
||||
|
||||
@@ -1,7 +1,6 @@
|
||||
"""Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT."""
|
||||
|
||||
from __future__ import annotations
|
||||
from enum import Enum
|
||||
from openrouter.types import (
|
||||
BaseModel,
|
||||
Nullable,
|
||||
@@ -11,18 +10,15 @@ from openrouter.types import (
|
||||
)
|
||||
import pydantic
|
||||
from pydantic import model_serializer
|
||||
from typing import Optional
|
||||
from typing import Literal, Optional
|
||||
from typing_extensions import Annotated, NotRequired, TypedDict
|
||||
|
||||
|
||||
class ReasoningDetailEncryptedType(str, Enum):
|
||||
REASONING_ENCRYPTED = "reasoning.encrypted"
|
||||
ReasoningDetailEncryptedType = Literal["reasoning.encrypted"]
|
||||
|
||||
|
||||
class ReasoningDetailEncryptedFormat(str, Enum):
|
||||
UNKNOWN = "unknown"
|
||||
OPENAI_RESPONSES_V1 = "openai-responses-v1"
|
||||
ANTHROPIC_CLAUDE_V1 = "anthropic-claude-v1"
|
||||
ReasoningDetailEncryptedFormat = Literal[
|
||||
"unknown", "openai-responses-v1", "anthropic-claude-v1"
|
||||
]
|
||||
|
||||
|
||||
class ReasoningDetailEncryptedTypedDict(TypedDict):
|
||||
@@ -46,7 +42,7 @@ class ReasoningDetailEncrypted(BaseModel):
|
||||
|
||||
format_: Annotated[
|
||||
OptionalNullable[ReasoningDetailEncryptedFormat], pydantic.Field(alias="format")
|
||||
] = ReasoningDetailEncryptedFormat.ANTHROPIC_CLAUDE_V1
|
||||
] = "anthropic-claude-v1"
|
||||
|
||||
index: Optional[float] = None
|
||||
|
||||
|
||||
@@ -1,7 +1,6 @@
|
||||
"""Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT."""
|
||||
|
||||
from __future__ import annotations
|
||||
from enum import Enum
|
||||
from openrouter.types import (
|
||||
BaseModel,
|
||||
Nullable,
|
||||
@@ -11,18 +10,15 @@ from openrouter.types import (
|
||||
)
|
||||
import pydantic
|
||||
from pydantic import model_serializer
|
||||
from typing import Optional
|
||||
from typing import Literal, Optional
|
||||
from typing_extensions import Annotated, NotRequired, TypedDict
|
||||
|
||||
|
||||
class ReasoningDetailSummaryType(str, Enum):
|
||||
REASONING_SUMMARY = "reasoning.summary"
|
||||
ReasoningDetailSummaryType = Literal["reasoning.summary"]
|
||||
|
||||
|
||||
class ReasoningDetailSummaryFormat(str, Enum):
|
||||
UNKNOWN = "unknown"
|
||||
OPENAI_RESPONSES_V1 = "openai-responses-v1"
|
||||
ANTHROPIC_CLAUDE_V1 = "anthropic-claude-v1"
|
||||
ReasoningDetailSummaryFormat = Literal[
|
||||
"unknown", "openai-responses-v1", "anthropic-claude-v1"
|
||||
]
|
||||
|
||||
|
||||
class ReasoningDetailSummaryTypedDict(TypedDict):
|
||||
@@ -46,7 +42,7 @@ class ReasoningDetailSummary(BaseModel):
|
||||
|
||||
format_: Annotated[
|
||||
OptionalNullable[ReasoningDetailSummaryFormat], pydantic.Field(alias="format")
|
||||
] = ReasoningDetailSummaryFormat.ANTHROPIC_CLAUDE_V1
|
||||
] = "anthropic-claude-v1"
|
||||
|
||||
index: Optional[float] = None
|
||||
|
||||
|
||||
@@ -1,7 +1,6 @@
|
||||
"""Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT."""
|
||||
|
||||
from __future__ import annotations
|
||||
from enum import Enum
|
||||
from openrouter.types import (
|
||||
BaseModel,
|
||||
Nullable,
|
||||
@@ -11,18 +10,15 @@ from openrouter.types import (
|
||||
)
|
||||
import pydantic
|
||||
from pydantic import model_serializer
|
||||
from typing import Optional
|
||||
from typing import Literal, Optional
|
||||
from typing_extensions import Annotated, NotRequired, TypedDict
|
||||
|
||||
|
||||
class ReasoningDetailTextType(str, Enum):
|
||||
REASONING_TEXT = "reasoning.text"
|
||||
ReasoningDetailTextType = Literal["reasoning.text"]
|
||||
|
||||
|
||||
class ReasoningDetailTextFormat(str, Enum):
|
||||
UNKNOWN = "unknown"
|
||||
OPENAI_RESPONSES_V1 = "openai-responses-v1"
|
||||
ANTHROPIC_CLAUDE_V1 = "anthropic-claude-v1"
|
||||
ReasoningDetailTextFormat = Literal[
|
||||
"unknown", "openai-responses-v1", "anthropic-claude-v1"
|
||||
]
|
||||
|
||||
|
||||
class ReasoningDetailTextTypedDict(TypedDict):
|
||||
@@ -49,7 +45,7 @@ class ReasoningDetailText(BaseModel):
|
||||
|
||||
format_: Annotated[
|
||||
OptionalNullable[ReasoningDetailTextFormat], pydantic.Field(alias="format")
|
||||
] = ReasoningDetailTextFormat.ANTHROPIC_CLAUDE_V1
|
||||
] = "anthropic-claude-v1"
|
||||
|
||||
index: Optional[float] = None
|
||||
|
||||
|
||||
@@ -8,11 +8,11 @@ from typing_extensions import Annotated, NotRequired, TypedDict
|
||||
|
||||
|
||||
class SecurityTypedDict(TypedDict):
|
||||
bearer_auth: NotRequired[str]
|
||||
api_key: NotRequired[str]
|
||||
|
||||
|
||||
class Security(BaseModel):
|
||||
bearer_auth: Annotated[
|
||||
api_key: Annotated[
|
||||
Optional[str],
|
||||
FieldMetadata(
|
||||
security=SecurityMetadata(
|
||||
|
||||
@@ -1,14 +1,12 @@
|
||||
"""Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT."""
|
||||
|
||||
from __future__ import annotations
|
||||
from enum import Enum
|
||||
from openrouter.types import BaseModel
|
||||
from typing import Optional
|
||||
from typing import Literal, Optional
|
||||
from typing_extensions import NotRequired, TypedDict
|
||||
|
||||
|
||||
class URLCitationAnnotationDetailType(str, Enum):
|
||||
URL_CITATION = "url_citation"
|
||||
URLCitationAnnotationDetailType = Literal["url_citation"]
|
||||
|
||||
|
||||
class URLCitationTypedDict(TypedDict):
|
||||
|
||||
+20
-7
@@ -10,6 +10,7 @@ import importlib
|
||||
from openrouter import models, utils
|
||||
from openrouter._hooks import SDKHooks
|
||||
from openrouter.types import OptionalNullable, UNSET
|
||||
import sys
|
||||
from typing import Any, Callable, Dict, List, Optional, TYPE_CHECKING, Union, cast
|
||||
import weakref
|
||||
|
||||
@@ -30,7 +31,7 @@ class OpenRouter(BaseSDK):
|
||||
|
||||
def __init__(
|
||||
self,
|
||||
bearer_auth: Optional[Union[Optional[str], Callable[[], Optional[str]]]] = None,
|
||||
api_key: Optional[Union[Optional[str], Callable[[], Optional[str]]]] = None,
|
||||
provider_url: Optional[str] = None,
|
||||
server_idx: Optional[int] = None,
|
||||
server_url: Optional[str] = None,
|
||||
@@ -43,7 +44,7 @@ class OpenRouter(BaseSDK):
|
||||
) -> None:
|
||||
r"""Instantiates the SDK configuring it with the provided parameters.
|
||||
|
||||
:param bearer_auth: The bearer_auth required for authentication
|
||||
:param api_key: The api_key required for authentication
|
||||
:param provider_url: Allows setting the provider_url variable for url substitution
|
||||
:param server_idx: The index of the server to use for all methods
|
||||
:param server_url: The server URL to use for all methods
|
||||
@@ -75,11 +76,11 @@ class OpenRouter(BaseSDK):
|
||||
), "The provided async_client must implement the AsyncHttpClient protocol."
|
||||
|
||||
security: Any = None
|
||||
if callable(bearer_auth):
|
||||
if callable(api_key):
|
||||
# pylint: disable=unnecessary-lambda-assignment
|
||||
security = lambda: models.Security(bearer_auth=bearer_auth())
|
||||
security = lambda: models.Security(api_key=api_key())
|
||||
else:
|
||||
security = models.Security(bearer_auth=bearer_auth)
|
||||
security = models.Security(api_key=api_key)
|
||||
|
||||
if server_url is not None:
|
||||
if url_params is not None:
|
||||
@@ -105,6 +106,7 @@ class OpenRouter(BaseSDK):
|
||||
timeout_ms=timeout_ms,
|
||||
debug_logger=debug_logger,
|
||||
),
|
||||
parent_ref=self,
|
||||
)
|
||||
|
||||
hooks = SDKHooks()
|
||||
@@ -124,13 +126,24 @@ class OpenRouter(BaseSDK):
|
||||
self.sdk_configuration.async_client_supplied,
|
||||
)
|
||||
|
||||
def dynamic_import(self, modname, retries=3):
|
||||
for attempt in range(retries):
|
||||
try:
|
||||
return importlib.import_module(modname)
|
||||
except KeyError:
|
||||
# Clear any half-initialized module and retry
|
||||
sys.modules.pop(modname, None)
|
||||
if attempt == retries - 1:
|
||||
break
|
||||
raise KeyError(f"Failed to import module '{modname}' after {retries} attempts")
|
||||
|
||||
def __getattr__(self, name: str):
|
||||
if name in self._sub_sdk_map:
|
||||
module_path, class_name = self._sub_sdk_map[name]
|
||||
try:
|
||||
module = importlib.import_module(module_path)
|
||||
module = self.dynamic_import(module_path)
|
||||
klass = getattr(module, class_name)
|
||||
instance = klass(self.sdk_configuration)
|
||||
instance = klass(self.sdk_configuration, parent_ref=self)
|
||||
setattr(self, name, instance)
|
||||
return instance
|
||||
except ImportError as e:
|
||||
|
||||
@@ -3,6 +3,7 @@
|
||||
from typing import TYPE_CHECKING
|
||||
from importlib import import_module
|
||||
import builtins
|
||||
import sys
|
||||
|
||||
if TYPE_CHECKING:
|
||||
from .annotations import get_discriminator
|
||||
@@ -162,6 +163,18 @@ _dynamic_imports: dict[str, str] = {
|
||||
}
|
||||
|
||||
|
||||
def dynamic_import(modname, retries=3):
|
||||
for attempt in range(retries):
|
||||
try:
|
||||
return import_module(modname, __package__)
|
||||
except KeyError:
|
||||
# Clear any half-initialized module and retry
|
||||
sys.modules.pop(modname, None)
|
||||
if attempt == retries - 1:
|
||||
break
|
||||
raise KeyError(f"Failed to import module '{modname}' after {retries} attempts")
|
||||
|
||||
|
||||
def __getattr__(attr_name: str) -> object:
|
||||
module_name = _dynamic_imports.get(attr_name)
|
||||
if module_name is None:
|
||||
@@ -170,9 +183,8 @@ def __getattr__(attr_name: str) -> object:
|
||||
)
|
||||
|
||||
try:
|
||||
module = import_module(module_name, __package__)
|
||||
result = getattr(module, attr_name)
|
||||
return result
|
||||
module = dynamic_import(module_name)
|
||||
return getattr(module, attr_name)
|
||||
except ImportError as e:
|
||||
raise ImportError(
|
||||
f"Failed to import {attr_name} from {module_name}: {e}"
|
||||
|
||||
@@ -17,6 +17,9 @@ T = TypeVar("T")
|
||||
|
||||
|
||||
class EventStream(Generic[T]):
|
||||
# Holds a reference to the SDK client to avoid it being garbage collected
|
||||
# and cause termination of the underlying httpx client.
|
||||
client_ref: Optional[object]
|
||||
response: httpx.Response
|
||||
generator: Generator[T, None, None]
|
||||
|
||||
@@ -25,9 +28,11 @@ class EventStream(Generic[T]):
|
||||
response: httpx.Response,
|
||||
decoder: Callable[[str], T],
|
||||
sentinel: Optional[str] = None,
|
||||
client_ref: Optional[object] = None,
|
||||
):
|
||||
self.response = response
|
||||
self.generator = stream_events(response, decoder, sentinel)
|
||||
self.client_ref = client_ref
|
||||
|
||||
def __iter__(self):
|
||||
return self
|
||||
@@ -43,6 +48,9 @@ class EventStream(Generic[T]):
|
||||
|
||||
|
||||
class EventStreamAsync(Generic[T]):
|
||||
# Holds a reference to the SDK client to avoid it being garbage collected
|
||||
# and cause termination of the underlying httpx client.
|
||||
client_ref: Optional[object]
|
||||
response: httpx.Response
|
||||
generator: AsyncGenerator[T, None]
|
||||
|
||||
@@ -51,9 +59,11 @@ class EventStreamAsync(Generic[T]):
|
||||
response: httpx.Response,
|
||||
decoder: Callable[[str], T],
|
||||
sentinel: Optional[str] = None,
|
||||
client_ref: Optional[object] = None,
|
||||
):
|
||||
self.response = response
|
||||
self.generator = stream_events_async(response, decoder, sentinel)
|
||||
self.client_ref = client_ref
|
||||
|
||||
def __aiter__(self):
|
||||
return self
|
||||
|
||||
@@ -64,8 +64,8 @@ def get_security_from_env(security: Any, security_class: Any) -> Optional[BaseMo
|
||||
|
||||
security_dict: Any = {}
|
||||
|
||||
if os.getenv("OPENROUTER_BEARER_AUTH"):
|
||||
security_dict["bearer_auth"] = os.getenv("OPENROUTER_BEARER_AUTH")
|
||||
if os.getenv("OPENROUTER_API_KEY"):
|
||||
security_dict["api_key"] = os.getenv("OPENROUTER_API_KEY")
|
||||
|
||||
return security_class(**security_dict) if security_dict else None
|
||||
|
||||
|
||||
Reference in New Issue
Block a user