"""Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT.""" from __future__ import annotations from openrouter.types import BaseModel, UNSET_SENTINEL from pydantic import model_serializer from typing import Literal, Optional from typing_extensions import NotRequired, TypedDict OutputCustomToolCallItemType = Literal["custom_tool_call",] class OutputCustomToolCallItemTypedDict(TypedDict): r"""A call to a custom (freeform-grammar) tool created by the model — distinct from `function_call`. Used for tools like Codex CLI's `apply_patch` whose payload is opaque text rather than JSON arguments.""" call_id: str input: str name: str type: OutputCustomToolCallItemType id: NotRequired[str] namespace: NotRequired[str] r"""Namespace qualifier for tools registered as part of a namespace tool group (e.g. an MCP server)""" class OutputCustomToolCallItem(BaseModel): r"""A call to a custom (freeform-grammar) tool created by the model — distinct from `function_call`. Used for tools like Codex CLI's `apply_patch` whose payload is opaque text rather than JSON arguments.""" call_id: str input: str name: str type: OutputCustomToolCallItemType id: Optional[str] = None namespace: Optional[str] = None r"""Namespace qualifier for tools registered as part of a namespace tool group (e.g. an MCP server)""" @model_serializer(mode="wrap") def serialize_model(self, handler): optional_fields = set(["id", "namespace"]) serialized = handler(self) m = {} for n, f in type(self).model_fields.items(): k = f.alias or n val = serialized.get(k, serialized.get(n)) if val != UNSET_SENTINEL: if val is not None or k not in optional_fields: m[k] = val return m