osyra.types
Typed response objects, OpenAI-wire-shaped.
These mirror the OpenAI ``/v1/chat/completions`` and ``/v1/embeddings`` response schemas (the public, documented OpenAI wire contract) so that code written against the upstream ``openai`` package parses Osyra responses unchanged. They are deliberately *not* the OSYRA-native edge DTO shape — see README "Edge wire gap" and the flag to /osyra-arch.
We use plain dataclasses (no pydantic) to keep the dependency surface to httpx only, per the AP00023 design (§9: "dep on httpx only").
Classes
class ChatCompletion (dataclass)
Attributes
| Name | Type | Default |
| --- | --- | --- |
| choices | List[Choice] | field(default_factory=list) |
| created | int | 0 |
| id | str | '' |
| model | str | '' |
| object | str | 'chat.completion' |
| provider | Optional[str] | None |
| usage | Optional[CompletionUsage] | None |
Methods
from_dict @classmethod
def from_dict(cls, d: Dict[str, Any]) -> 'ChatCompletion'class ChatCompletionChunk (dataclass)
Attributes
| Name | Type | Default |
| --- | --- | --- |
| choices | List[ChunkChoice] | field(default_factory=list) |
| created | int | 0 |
| id | str | '' |
| model | str | '' |
| object | str | 'chat.completion.chunk' |
| provider | Optional[str] | None |
Methods
from_dict @classmethod
def from_dict(cls, d: Dict[str, Any]) -> 'ChatCompletionChunk'class ChatCompletionMessage (dataclass)
Attributes
| Name | Type | Default |
| --- | --- | --- |
| content | Optional[str] | None |
| role | str | 'assistant' |
Methods
from_dict @classmethod
def from_dict(cls, d: Optional[Dict[str, Any]]) -> 'ChatCompletionMessage'class Choice (dataclass)
Attributes
| Name | Type | Default |
| --- | --- | --- |
| finish_reason | Optional[str] | None |
| index | int | 0 |
| message | ChatCompletionMessage | field(default_factory=ChatCompletionMessage) |
Methods
from_dict @classmethod
def from_dict(cls, d: Dict[str, Any]) -> 'Choice'class ChoiceDelta (dataclass)
Attributes
| Name | Type | Default |
| --- | --- | --- |
| content | Optional[str] | None |
| role | Optional[str] | None |
Methods
from_dict @classmethod
def from_dict(cls, d: Optional[Dict[str, Any]]) -> 'ChoiceDelta'class ChunkChoice (dataclass)
Attributes
| Name | Type | Default |
| --- | --- | --- |
| delta | ChoiceDelta | field(default_factory=ChoiceDelta) |
| finish_reason | Optional[str] | None |
| index | int | 0 |
Methods
from_dict @classmethod
def from_dict(cls, d: Dict[str, Any]) -> 'ChunkChoice'class CompletionUsage (dataclass)
Attributes
| Name | Type | Default |
| --- | --- | --- |
| completion_tokens | int | 0 |
| estimated_cost_microcents | Optional[int] | None |
| prompt_tokens | int | 0 |
| total_tokens | int | 0 |
Methods
from_dict @classmethod
def from_dict(cls, d: Optional[Dict[str, Any]]) -> Optional['CompletionUsage']class CreateEmbeddingResponse (dataclass)
Attributes
| Name | Type | Default |
| --- | --- | --- |
| data | List[Embedding] | field(default_factory=list) |
| model | str | '' |
| object | str | 'list' |
| provider | Optional[str] | None |
| usage | Optional[CompletionUsage] | None |
Methods
from_dict @classmethod
def from_dict(cls, d: Dict[str, Any]) -> 'CreateEmbeddingResponse'class Embedding (dataclass)
Attributes
| Name | Type | Default |
| --- | --- | --- |
| embedding | List[float] | field(default_factory=list) |
| index | int | 0 |
| object | str | 'embedding' |
Methods
from_dict @classmethod
def from_dict(cls, d: Dict[str, Any]) -> 'Embedding'class Model (dataclass)
One model, OpenAI ``/v1/models``-shaped (``id``/``object``/``created``/ ``owned_by``) with the OSYRA-native broker fields surfaced as additive extensions (``provider``/``context_window``/``max_output_tokens``/cost/ ``capabilities``/``available``). A native OpenAI client reads ``id``; OSYRA callers can read the routing/cost metadata.
Attributes
| Name | Type | Default |
| --- | --- | --- |
| available | Optional[bool] | None |
| capabilities | Optional[Dict[str, Any]] | None |
| context_window | Optional[int] | None |
| created | int | 0 |
| id | str | '' |
| input_cost_per_1k | Optional[int] | None |
| max_output_tokens | Optional[int] | None |
| object | str | 'model' |
| output_cost_per_1k | Optional[int] | None |
| owned_by | str | '' |
| provider | Optional[str] | None |
| type | Optional[str] | None |
Methods
from_dict @classmethod
def from_dict(cls, d: Dict[str, Any]) -> 'Model'class ModelList (dataclass)
The OpenAI ``/v1/models`` list envelope: ``{object:"list", data:[Model]}``.
Supports ``len(...)``, iteration, and indexing so ``for m in client.models.list()`` works exactly like the upstream ``openai`` package's ``SyncPage[Model]``.
Attributes
| Name | Type | Default |
| --- | --- | --- |
| data | List[Model] | field(default_factory=list) |
| object | str | 'list' |
Methods
from_response @classmethod
def from_response(cls, d: Any) -> 'ModelList'