# generated by datamodel-codegen:
#   filename:  <stdin>
#   timestamp: 2024-10-26T15:24:12+00:00

from __future__ import annotations

from enum import Enum
from typing import Any, Dict, List, Optional, Union

from pydantic import AnyUrl, BaseModel, ConfigDict, Field, RootModel


class AddUploadPartRequest(BaseModel):
    model_config = ConfigDict(
        extra='forbid',
    )
    data: bytes
    """
    The chunk of bytes for this Part.

    """


class Object(str, Enum):
    """
    The object type, which is always `assistant`.
    """

    assistant = 'assistant'


class CodeInterpreter(BaseModel):
    file_ids: List[str] = Field([], max_length=20)
    """
    A list of [file](/docs/api-reference/files) IDs made available to the `code_interpreter`` tool. There can be a maximum of 20 files associated with the tool.

    """


class FileSearch(BaseModel):
    vector_store_ids: Optional[List[str]] = Field(None, max_length=1)
    """
    The ID of the [vector store](/docs/api-reference/vector-stores/object) attached to this assistant. There can be a maximum of 1 vector store attached to the assistant.

    """


class ToolResources(BaseModel):
    """
    A set of resources that are used by the assistant's tools. The resources are specific to the type of tool. For example, the `code_interpreter` tool requires a list of file IDs, while the `file_search` tool requires a list of vector store IDs.

    """

    code_interpreter: Optional[CodeInterpreter] = None
    file_search: Optional[FileSearch] = None


class Type(str, Enum):
    """
    The type of tool being defined: `code_interpreter`
    """

    code_interpreter = 'code_interpreter'


class AssistantToolsCode(BaseModel):
    type: Type
    """
    The type of tool being defined: `code_interpreter`
    """


class Type1(str, Enum):
    """
    The type of tool being defined: `file_search`
    """

    file_search = 'file_search'


class AssistantToolsFileSearchTypeOnly(BaseModel):
    type: Type1
    """
    The type of tool being defined: `file_search`
    """


class Type3(str, Enum):
    """
    The type of tool being defined: `function`
    """

    function = 'function'


class AssistantsApiResponseFormatOption1(str, Enum):
    """
    `auto` is the default value

    """

    auto = 'auto'


class AssistantsApiToolChoiceOption1(str, Enum):
    """
    `none` means the model will not call any tools and instead generates a message. `auto` means the model can pick between generating a message or calling one or more tools. `required` means the model must call one or more tools before responding to the user.

    """

    none = 'none'
    auto = 'auto'
    required = 'required'


class Type4(str, Enum):
    """
    The type of the tool. If type is `function`, the function name must be set
    """

    function = 'function'
    code_interpreter = 'code_interpreter'
    file_search = 'file_search'


class Function(BaseModel):
    name: str
    """
    The name of the function to call.
    """


class AssistantsNamedToolChoice(BaseModel):
    """
    Specifies a tool the model should use. Use to force the model to call a specific tool.
    """

    type: Type4
    """
    The type of the tool. If type is `function`, the function name must be set
    """
    function: Optional[Function] = None


class AudioResponseFormat(str, Enum):
    """
    The format of the output, in one of these options: `json`, `text`, `srt`, `verbose_json`, or `vtt`.

    """

    json = 'json'
    text = 'text'
    srt = 'srt'
    verbose_json = 'verbose_json'
    vtt = 'vtt'


class Project(BaseModel):
    """
    The project that the action was scoped to. Absent for actions not scoped to projects.
    """

    id: Optional[str] = None
    """
    The project ID.
    """
    name: Optional[str] = None
    """
    The project title.
    """


class Data(BaseModel):
    """
    The payload used to create the API key.
    """

    scopes: Optional[List[str]] = None
    """
    A list of scopes allowed for the API key, e.g. `["api.model.request"]`
    """


class ApiKeyCreated(BaseModel):
    """
    The details for events with this `type`.
    """

    id: Optional[str] = None
    """
    The tracking ID of the API key.
    """
    data: Optional[Data] = None
    """
    The payload used to create the API key.
    """


class ChangesRequested(BaseModel):
    """
    The payload used to update the API key.
    """

    scopes: Optional[List[str]] = None
    """
    A list of scopes allowed for the API key, e.g. `["api.model.request"]`
    """


class ApiKeyUpdated(BaseModel):
    """
    The details for events with this `type`.
    """

    id: Optional[str] = None
    """
    The tracking ID of the API key.
    """
    changes_requested: Optional[ChangesRequested] = None
    """
    The payload used to update the API key.
    """


class ApiKeyDeleted(BaseModel):
    """
    The details for events with this `type`.
    """

    id: Optional[str] = None
    """
    The tracking ID of the API key.
    """


class Data1(BaseModel):
    """
    The payload used to create the invite.
    """

    email: Optional[str] = None
    """
    The email invited to the organization.
    """
    role: Optional[str] = None
    """
    The role the email was invited to be. Is either `owner` or `member`.
    """


class InviteSent(BaseModel):
    """
    The details for events with this `type`.
    """

    id: Optional[str] = None
    """
    The ID of the invite.
    """
    data: Optional[Data1] = None
    """
    The payload used to create the invite.
    """


class InviteAccepted(BaseModel):
    """
    The details for events with this `type`.
    """

    id: Optional[str] = None
    """
    The ID of the invite.
    """


class InviteDeleted(InviteAccepted):
    """
    The details for events with this `type`.
    """


class LoginFailed(BaseModel):
    """
    The details for events with this `type`.
    """

    error_code: Optional[str] = None
    """
    The error code of the failure.
    """
    error_message: Optional[str] = None
    """
    The error message of the failure.
    """


class LogoutFailed(LoginFailed):
    """
    The details for events with this `type`.
    """


class Settings(BaseModel):
    threads_ui_visibility: Optional[str] = None
    """
    Visibility of the threads page which shows messages created with the Assistants API and Playground. One of `ANY_ROLE`, `OWNERS`, or `NONE`.
    """
    usage_dashboard_visibility: Optional[str] = None
    """
    Visibility of the usage dashboard which shows activity and costs for your organization. One of `ANY_ROLE` or `OWNERS`.
    """


class ChangesRequested1(BaseModel):
    """
    The payload used to update the organization settings.
    """

    title: Optional[str] = None
    """
    The organization title.
    """
    description: Optional[str] = None
    """
    The organization description.
    """
    name: Optional[str] = None
    """
    The organization name.
    """
    settings: Optional[Settings] = None


class OrganizationUpdated(BaseModel):
    """
    The details for events with this `type`.
    """

    id: Optional[str] = None
    """
    The organization ID.
    """
    changes_requested: Optional[ChangesRequested1] = None
    """
    The payload used to update the organization settings.
    """


class Data2(BaseModel):
    """
    The payload used to create the project.
    """

    name: Optional[str] = None
    """
    The project name.
    """
    title: Optional[str] = None
    """
    The title of the project as seen on the dashboard.
    """


class ProjectCreated(BaseModel):
    """
    The details for events with this `type`.
    """

    id: Optional[str] = None
    """
    The project ID.
    """
    data: Optional[Data2] = None
    """
    The payload used to create the project.
    """


class ChangesRequested2(BaseModel):
    """
    The payload used to update the project.
    """

    title: Optional[str] = None
    """
    The title of the project as seen on the dashboard.
    """


class ProjectUpdated(BaseModel):
    """
    The details for events with this `type`.
    """

    id: Optional[str] = None
    """
    The project ID.
    """
    changes_requested: Optional[ChangesRequested2] = None
    """
    The payload used to update the project.
    """


class ProjectArchived(BaseModel):
    """
    The details for events with this `type`.
    """

    id: Optional[str] = None
    """
    The project ID.
    """


class Data3(BaseModel):
    """
    The payload used to create the service account.
    """

    role: Optional[str] = None
    """
    The role of the service account. Is either `owner` or `member`.
    """


class ServiceAccountCreated(BaseModel):
    """
    The details for events with this `type`.
    """

    id: Optional[str] = None
    """
    The service account ID.
    """
    data: Optional[Data3] = None
    """
    The payload used to create the service account.
    """


class ChangesRequested3(BaseModel):
    """
    The payload used to updated the service account.
    """

    role: Optional[str] = None
    """
    The role of the service account. Is either `owner` or `member`.
    """


class ServiceAccountUpdated(BaseModel):
    """
    The details for events with this `type`.
    """

    id: Optional[str] = None
    """
    The service account ID.
    """
    changes_requested: Optional[ChangesRequested3] = None
    """
    The payload used to updated the service account.
    """


class ServiceAccountDeleted(BaseModel):
    """
    The details for events with this `type`.
    """

    id: Optional[str] = None
    """
    The service account ID.
    """


class Data4(BaseModel):
    """
    The payload used to add the user to the project.
    """

    role: Optional[str] = None
    """
    The role of the user. Is either `owner` or `member`.
    """


class UserAdded(BaseModel):
    """
    The details for events with this `type`.
    """

    id: Optional[str] = None
    """
    The user ID.
    """
    data: Optional[Data4] = None
    """
    The payload used to add the user to the project.
    """


class ChangesRequested4(BaseModel):
    """
    The payload used to update the user.
    """

    role: Optional[str] = None
    """
    The role of the user. Is either `owner` or `member`.
    """


class UserUpdated(BaseModel):
    """
    The details for events with this `type`.
    """

    id: Optional[str] = None
    """
    The project ID.
    """
    changes_requested: Optional[ChangesRequested4] = None
    """
    The payload used to update the user.
    """


class UserDeleted(BaseModel):
    """
    The details for events with this `type`.
    """

    id: Optional[str] = None
    """
    The user ID.
    """


class Type5(str, Enum):
    """
    The type of actor. Is either `session` or `api_key`.
    """

    session = 'session'
    api_key = 'api_key'


class Type6(str, Enum):
    """
    The type of API key. Can be either `user` or `service_account`.
    """

    user = 'user'
    service_account = 'service_account'


class AuditLogActorServiceAccount(BaseModel):
    """
    The service account that performed the audit logged action.
    """

    id: Optional[str] = None
    """
    The service account id.
    """


class AuditLogActorUser(BaseModel):
    """
    The user who performed the audit logged action.
    """

    id: Optional[str] = None
    """
    The user id.
    """
    email: Optional[str] = None
    """
    The user email.
    """


class AuditLogEventType(str, Enum):
    """
    The event type.
    """

    api_key_created = 'api_key.created'
    api_key_updated = 'api_key.updated'
    api_key_deleted = 'api_key.deleted'
    invite_sent = 'invite.sent'
    invite_accepted = 'invite.accepted'
    invite_deleted = 'invite.deleted'
    login_succeeded = 'login.succeeded'
    login_failed = 'login.failed'
    logout_succeeded = 'logout.succeeded'
    logout_failed = 'logout.failed'
    organization_updated = 'organization.updated'
    project_created = 'project.created'
    project_updated = 'project.updated'
    project_archived = 'project.archived'
    service_account_created = 'service_account.created'
    service_account_updated = 'service_account.updated'
    service_account_deleted = 'service_account.deleted'
    user_added = 'user.added'
    user_updated = 'user.updated'
    user_deleted = 'user.deleted'


class Type7(str, Enum):
    """
    Always `auto`.
    """

    auto = 'auto'


class AutoChunkingStrategyRequestParam(BaseModel):
    """
    The default strategy. This strategy currently uses a `max_chunk_size_tokens` of `800` and `chunk_overlap_tokens` of `400`.
    """

    model_config = ConfigDict(
        extra='forbid',
    )
    type: Type7
    """
    Always `auto`.
    """


class Object1(str, Enum):
    """
    The object type, which is always `batch`.
    """

    batch = 'batch'


class Datum(BaseModel):
    code: Optional[str] = None
    """
    An error code identifying the error type.
    """
    message: Optional[str] = None
    """
    A human-readable message providing more details about the error.
    """
    param: Optional[str] = None
    """
    The name of the parameter that caused the error, if applicable.
    """
    line: Optional[int] = None
    """
    The line number of the input file where the error occurred, if applicable.
    """


class Errors(BaseModel):
    object: Optional[str] = None
    """
    The object type, which is always `list`.
    """
    data: Optional[List[Datum]] = None


class Status(str, Enum):
    """
    The current status of the batch.
    """

    validating = 'validating'
    failed = 'failed'
    in_progress = 'in_progress'
    finalizing = 'finalizing'
    completed = 'completed'
    expired = 'expired'
    cancelling = 'cancelling'
    cancelled = 'cancelled'


class RequestCounts(BaseModel):
    """
    The request counts for different statuses within the batch.
    """

    total: int
    """
    Total number of requests in the batch.
    """
    completed: int
    """
    Number of requests that have been completed successfully.
    """
    failed: int
    """
    Number of requests that have failed.
    """


class Batch(BaseModel):
    id: str
    object: Object1
    """
    The object type, which is always `batch`.
    """
    endpoint: str
    """
    The OpenAI API endpoint used by the batch.
    """
    errors: Optional[Errors] = None
    input_file_id: str
    """
    The ID of the input file for the batch.
    """
    completion_window: str
    """
    The time frame within which the batch should be processed.
    """
    status: Status
    """
    The current status of the batch.
    """
    output_file_id: Optional[str] = None
    """
    The ID of the file containing the outputs of successfully executed requests.
    """
    error_file_id: Optional[str] = None
    """
    The ID of the file containing the outputs of requests with errors.
    """
    created_at: int
    """
    The Unix timestamp (in seconds) for when the batch was created.
    """
    in_progress_at: Optional[int] = None
    """
    The Unix timestamp (in seconds) for when the batch started processing.
    """
    expires_at: Optional[int] = None
    """
    The Unix timestamp (in seconds) for when the batch will expire.
    """
    finalizing_at: Optional[int] = None
    """
    The Unix timestamp (in seconds) for when the batch started finalizing.
    """
    completed_at: Optional[int] = None
    """
    The Unix timestamp (in seconds) for when the batch was completed.
    """
    failed_at: Optional[int] = None
    """
    The Unix timestamp (in seconds) for when the batch failed.
    """
    expired_at: Optional[int] = None
    """
    The Unix timestamp (in seconds) for when the batch expired.
    """
    cancelling_at: Optional[int] = None
    """
    The Unix timestamp (in seconds) for when the batch started cancelling.
    """
    cancelled_at: Optional[int] = None
    """
    The Unix timestamp (in seconds) for when the batch was cancelled.
    """
    request_counts: Optional[RequestCounts] = None
    """
    The request counts for different statuses within the batch.
    """
    metadata: Optional[Dict[str, Any]] = None
    """
    Set of 16 key-value pairs that can be attached to an object. This can be useful for storing additional information about the object in a structured format. Keys can be a maximum of 64 characters long and values can be a maximum of 512 characters long.

    """


class Method(str, Enum):
    """
    The HTTP method to be used for the request. Currently only `POST` is supported.
    """

    POST = 'POST'


class BatchRequestInput(BaseModel):
    """
    The per-line object of the batch input file
    """

    custom_id: Optional[str] = None
    """
    A developer-provided per-request id that will be used to match outputs to inputs. Must be unique for each request in a batch.
    """
    method: Optional[Method] = None
    """
    The HTTP method to be used for the request. Currently only `POST` is supported.
    """
    url: Optional[str] = None
    """
    The OpenAI API relative URL to be used for the request. Currently `/v1/chat/completions`, `/v1/embeddings`, and `/v1/completions` are supported.
    """


class Response(BaseModel):
    status_code: Optional[int] = None
    """
    The HTTP status code of the response
    """
    request_id: Optional[str] = None
    """
    An unique identifier for the OpenAI API request. Please include this request ID when contacting support.
    """
    body: Optional[Dict[str, Any]] = None
    """
    The JSON body of the response
    """


class Error(BaseModel):
    """
    For requests that failed with a non-HTTP error, this will contain more information on the cause of the failure.
    """

    code: Optional[str] = None
    """
    A machine-readable error code.
    """
    message: Optional[str] = None
    """
    A human-readable error message.
    """


class BatchRequestOutput(BaseModel):
    """
    The per-line object of the batch output and error files
    """

    id: Optional[str] = None
    custom_id: Optional[str] = None
    """
    A developer-provided per-request id that will be used to match outputs to inputs.
    """
    response: Optional[Response] = None
    error: Optional[Error] = None
    """
    For requests that failed with a non-HTTP error, this will contain more information on the cause of the failure.
    """


class CancelUploadRequest(BaseModel):
    pass
    model_config = ConfigDict(
        extra='forbid',
    )


class ChatCompletionFunctionCallOption(BaseModel):
    """
    Specifying a particular function via `{"name": "my_function"}` forces the model to call that function.

    """

    name: str
    """
    The name of the function to call.
    """


class Type8(str, Enum):
    """
    The type of the tool. Currently, only `function` is supported.
    """

    function = 'function'


class Function1(BaseModel):
    """
    The function that the model called.
    """

    name: str
    """
    The name of the function to call.
    """
    arguments: str
    """
    The arguments to call the function with, as generated by the model in JSON format. Note that the model does not always generate valid JSON, and may hallucinate parameters not defined by your function schema. Validate the arguments in your code before calling your function.
    """


class ChatCompletionMessageToolCall(BaseModel):
    id: str
    """
    The ID of the tool call.
    """
    type: Type8
    """
    The type of the tool. Currently, only `function` is supported.
    """
    function: Function1
    """
    The function that the model called.
    """


class Function2(BaseModel):
    name: Optional[str] = None
    """
    The name of the function to call.
    """
    arguments: Optional[str] = None
    """
    The arguments to call the function with, as generated by the model in JSON format. Note that the model does not always generate valid JSON, and may hallucinate parameters not defined by your function schema. Validate the arguments in your code before calling your function.
    """


class ChatCompletionMessageToolCallChunk(BaseModel):
    index: int
    id: Optional[str] = None
    """
    The ID of the tool call.
    """
    type: Optional[Type8] = None
    """
    The type of the tool. Currently, only `function` is supported.
    """
    function: Optional[Function2] = None


class ChatCompletionMessageToolCalls(RootModel[List[ChatCompletionMessageToolCall]]):
    """
    The tool calls generated by the model, such as function calls.
    """

    root: List[ChatCompletionMessageToolCall]
    """
    The tool calls generated by the model, such as function calls.
    """


class ChatCompletionModality(str, Enum):
    text = 'text'
    audio = 'audio'


class ChatCompletionModalities(RootModel[Optional[List[ChatCompletionModality]]]):
    """
    Output types that you would like the model to generate for this request.
    Most models are capable of generating text, which is the default:

    `["text"]`

    The `gpt-4o-audio-preview` model can also be used to [generate audio](/docs/guides/audio). To
    request that this model generate both text and audio responses, you can
    use:

    `["text", "audio"]`

    """

    root: Optional[List[ChatCompletionModality]] = Field(None)
    """
    Output types that you would like the model to generate for this request.
    Most models are capable of generating text, which is the default:

    `["text"]`

    The `gpt-4o-audio-preview` model can also be used to [generate audio](/docs/guides/audio). To
    request that this model generate both text and audio responses, you can
    use:

    `["text", "audio"]`

    """


class Function3(Function):
    pass


class ChatCompletionNamedToolChoice(BaseModel):
    """
    Specifies a tool the model should use. Use to force the model to call a specific function.
    """

    type: Type8
    """
    The type of the tool. Currently, only `function` is supported.
    """
    function: Function3


class Role(str, Enum):
    """
    The role of the messages author, in this case `assistant`.
    """

    assistant = 'assistant'


class Audio(BaseModel):
    """
    Data about a previous audio response from the model.
    [Learn more](/docs/guides/audio).

    """

    id: str
    """
    Unique identifier for a previous audio response from the model.

    """


class FunctionCall(BaseModel):
    """
    Deprecated and replaced by `tool_calls`. The name and arguments of a function that should be called, as generated by the model.
    """

    arguments: str
    """
    The arguments to call the function with, as generated by the model in JSON format. Note that the model does not always generate valid JSON, and may hallucinate parameters not defined by your function schema. Validate the arguments in your code before calling your function.
    """
    name: str
    """
    The name of the function to call.
    """


class Role1(str, Enum):
    """
    The role of the messages author, in this case `function`.
    """

    function = 'function'


class ChatCompletionRequestFunctionMessage(BaseModel):
    role: Role1
    """
    The role of the messages author, in this case `function`.
    """
    content: Optional[str] = Field(None)
    """
    The contents of the function message.
    """
    name: str
    """
    The name of the function to call.
    """


class Type11(str, Enum):
    """
    The type of the content part. Always `input_audio`.
    """

    input_audio = 'input_audio'


class Format(str, Enum):
    """
    The format of the encoded audio data. Currently supports "wav" and "mp3".

    """

    wav = 'wav'
    mp3 = 'mp3'


class InputAudio(BaseModel):
    data: str
    """
    Base64 encoded audio data.
    """
    format: Format
    """
    The format of the encoded audio data. Currently supports "wav" and "mp3".

    """


class ChatCompletionRequestMessageContentPartAudio(BaseModel):
    """
    Learn about [audio inputs](/docs/guides/audio).

    """

    type: Type11
    """
    The type of the content part. Always `input_audio`.
    """
    input_audio: InputAudio


class Type12(str, Enum):
    """
    The type of the content part.
    """

    image_url = 'image_url'


class Detail(str, Enum):
    """
    Specifies the detail level of the image. Learn more in the [Vision guide](/docs/guides/vision/low-or-high-fidelity-image-understanding).
    """

    auto = 'auto'
    low = 'low'
    high = 'high'


class ImageUrl(BaseModel):
    url: AnyUrl
    """
    Either a URL of the image or the base64 encoded image data.
    """
    detail: Detail = 'auto'
    """
    Specifies the detail level of the image. Learn more in the [Vision guide](/docs/guides/vision/low-or-high-fidelity-image-understanding).
    """


class ChatCompletionRequestMessageContentPartImage(BaseModel):
    """
    Learn about [image inputs](/docs/guides/vision).

    """

    type: Type12
    """
    The type of the content part.
    """
    image_url: ImageUrl


class Type13(str, Enum):
    """
    The type of the content part.
    """

    refusal = 'refusal'


class ChatCompletionRequestMessageContentPartRefusal(BaseModel):
    type: Type13
    """
    The type of the content part.
    """
    refusal: str
    """
    The refusal message generated by the model.
    """


class Type14(str, Enum):
    """
    The type of the content part.
    """

    text = 'text'


class ChatCompletionRequestMessageContentPartText(BaseModel):
    """
    Learn about [text inputs](/docs/guides/text-generation).

    """

    type: Type14
    """
    The type of the content part.
    """
    text: str
    """
    The text content.
    """


class Role2(str, Enum):
    """
    The role of the messages author, in this case `system`.
    """

    system = 'system'


class ChatCompletionRequestSystemMessageContentPart(
    RootModel[ChatCompletionRequestMessageContentPartText]
):
    root: ChatCompletionRequestMessageContentPartText


class Role3(str, Enum):
    """
    The role of the messages author, in this case `tool`.
    """

    tool = 'tool'


class ChatCompletionRequestToolMessageContentPart(
    ChatCompletionRequestSystemMessageContentPart
):
    pass


class Role4(str, Enum):
    """
    The role of the messages author, in this case `user`.
    """

    user = 'user'


class ChatCompletionRequestUserMessageContentPart(
    RootModel[
        Union[
            ChatCompletionRequestMessageContentPartText,
            ChatCompletionRequestMessageContentPartImage,
            ChatCompletionRequestMessageContentPartAudio,
        ]
    ]
):
    root: Union[
        ChatCompletionRequestMessageContentPartText,
        ChatCompletionRequestMessageContentPartImage,
        ChatCompletionRequestMessageContentPartAudio,
    ]


class Role5(str, Enum):
    """
    The role of the author of this message.
    """

    assistant = 'assistant'


class Audio1(BaseModel):
    """
    If the audio output modality is requested, this object contains data
    about the audio response from the model. [Learn more](/docs/guides/audio).

    """

    id: str
    """
    Unique identifier for this audio response.
    """
    expires_at: int
    """
    The Unix timestamp (in seconds) for when this audio response will
    no longer be accessible on the server for use in multi-turn
    conversations.

    """
    data: str
    """
    Base64 encoded audio bytes generated by the model, in the format
    specified in the request.

    """
    transcript: str
    """
    Transcript of the audio generated by the model.
    """


class ChatCompletionResponseMessage(BaseModel):
    """
    A chat completion message generated by the model.
    """

    content: Optional[str] = Field(None)
    """
    The contents of the message.
    """
    refusal: Optional[str] = Field(None)
    """
    The refusal message generated by the model.
    """
    tool_calls: Optional[ChatCompletionMessageToolCalls] = None
    role: Role5
    """
    The role of the author of this message.
    """
    function_call: Optional[FunctionCall] = None
    """
    Deprecated and replaced by `tool_calls`. The name and arguments of a function that should be called, as generated by the model.
    """
    audio: Optional[Audio1] = None
    """
    If the audio output modality is requested, this object contains data
    about the audio response from the model. [Learn more](/docs/guides/audio).

    """


class ChatCompletionRole(str, Enum):
    """
    The role of the author of a message
    """

    system = 'system'
    user = 'user'
    assistant = 'assistant'
    tool = 'tool'
    function = 'function'


class ChatCompletionStreamOptions(BaseModel):
    """
    Options for streaming response. Only set this when you set `stream: true`.

    """

    include_usage: Optional[bool] = None
    """
    If set, an additional chunk will be streamed before the `data: [DONE]` message. The `usage` field on this chunk shows the token usage statistics for the entire request, and the `choices` field will always be an empty array. All other chunks will also include a `usage` field, but with a null value.

    """


class FunctionCall2(BaseModel):
    """
    Deprecated and replaced by `tool_calls`. The name and arguments of a function that should be called, as generated by the model.
    """

    arguments: Optional[str] = None
    """
    The arguments to call the function with, as generated by the model in JSON format. Note that the model does not always generate valid JSON, and may hallucinate parameters not defined by your function schema. Validate the arguments in your code before calling your function.
    """
    name: Optional[str] = None
    """
    The name of the function to call.
    """


class Role6(str, Enum):
    """
    The role of the author of this message.
    """

    system = 'system'
    user = 'user'
    assistant = 'assistant'
    tool = 'tool'


class ChatCompletionStreamResponseDelta(BaseModel):
    """
    A chat completion delta generated by streamed model responses.
    """

    content: Optional[str] = None
    """
    The contents of the chunk message.
    """
    function_call: Optional[FunctionCall2] = None
    """
    Deprecated and replaced by `tool_calls`. The name and arguments of a function that should be called, as generated by the model.
    """
    tool_calls: Optional[List[ChatCompletionMessageToolCallChunk]] = None
    role: Optional[Role6] = None
    """
    The role of the author of this message.
    """
    refusal: Optional[str] = None
    """
    The refusal message generated by the model.
    """


class TopLogprob(BaseModel):
    token: str
    """
    The token.
    """
    logprob: float
    """
    The log probability of this token, if it is within the top 20 most likely tokens. Otherwise, the value `-9999.0` is used to signify that the token is very unlikely.
    """
    bytes: Optional[List[int]] = Field(None)
    """
    A list of integers representing the UTF-8 bytes representation of the token. Useful in instances where characters are represented by multiple tokens and their byte representations must be combined to generate the correct text representation. Can be `null` if there is no bytes representation for the token.
    """


class ChatCompletionTokenLogprob(BaseModel):
    token: str
    """
    The token.
    """
    logprob: float
    """
    The log probability of this token, if it is within the top 20 most likely tokens. Otherwise, the value `-9999.0` is used to signify that the token is very unlikely.
    """
    bytes: Optional[List[int]] = Field(None)
    """
    A list of integers representing the UTF-8 bytes representation of the token. Useful in instances where characters are represented by multiple tokens and their byte representations must be combined to generate the correct text representation. Can be `null` if there is no bytes representation for the token.
    """
    top_logprobs: List[TopLogprob]
    """
    List of the most likely tokens and their log probability, at this token position. In rare cases, there may be fewer than the number of requested `top_logprobs` returned.
    """


class ChatCompletionToolChoiceOption1(str, Enum):
    """
    `none` means the model will not call any tool and instead generates a message. `auto` means the model can pick between generating a message or calling one or more tools. `required` means the model must call one or more tools.

    """

    none = 'none'
    auto = 'auto'
    required = 'required'


class ChatCompletionToolChoiceOption(
    RootModel[Union[ChatCompletionToolChoiceOption1, ChatCompletionNamedToolChoice]]
):
    root: Union[ChatCompletionToolChoiceOption1, ChatCompletionNamedToolChoice]
    """
    Controls which (if any) tool is called by the model.
    `none` means the model will not call any tool and instead generates a message.
    `auto` means the model can pick between generating a message or calling one or more tools.
    `required` means the model must call one or more tools.
    Specifying a particular tool via `{"type": "function", "function": {"name": "my_function"}}` forces the model to call that tool.

    `none` is the default when no tools are present. `auto` is the default if tools are present.

    """


class CompleteUploadRequest(BaseModel):
    model_config = ConfigDict(
        extra='forbid',
    )
    part_ids: List[str]
    """
    The ordered list of Part IDs.

    """
    md5: Optional[str] = None
    """
    The optional md5 checksum for the file contents to verify if the bytes uploaded matches what you expect.

    """


class CompletionTokensDetails(BaseModel):
    """
    Breakdown of tokens used in a completion.
    """

    audio_tokens: Optional[int] = None
    """
    Audio input tokens generated by the model.
    """
    reasoning_tokens: Optional[int] = None
    """
    Tokens generated by the model for reasoning.
    """


class PromptTokensDetails(BaseModel):
    """
    Breakdown of tokens used in the prompt.
    """

    audio_tokens: Optional[int] = None
    """
    Audio input tokens present in the prompt.
    """
    cached_tokens: Optional[int] = None
    """
    Cached tokens present in the prompt.
    """


class CompletionUsage(BaseModel):
    """
    Usage statistics for the completion request.
    """

    completion_tokens: int
    """
    Number of tokens in the generated completion.
    """
    prompt_tokens: int
    """
    Number of tokens in the prompt.
    """
    total_tokens: int
    """
    Total number of tokens used in the request (prompt + completion).
    """
    completion_tokens_details: Optional[CompletionTokensDetails] = None
    """
    Breakdown of tokens used in a completion.
    """
    prompt_tokens_details: Optional[PromptTokensDetails] = None
    """
    Breakdown of tokens used in the prompt.
    """


class Model(str, Enum):
    """
    ID of the model to use. You can use the [List models](/docs/api-reference/models/list) API to see all of your available models, or see our [Model overview](/docs/models/overview) for descriptions of them.

    """

    gpt_4o = 'gpt-4o'
    gpt_4o_2024_08_06 = 'gpt-4o-2024-08-06'
    gpt_4o_2024_05_13 = 'gpt-4o-2024-05-13'
    gpt_4o_2024_08_06_1 = 'gpt-4o-2024-08-06'
    gpt_4o_mini = 'gpt-4o-mini'
    gpt_4o_mini_2024_07_18 = 'gpt-4o-mini-2024-07-18'
    gpt_4_turbo = 'gpt-4-turbo'
    gpt_4_turbo_2024_04_09 = 'gpt-4-turbo-2024-04-09'
    gpt_4_0125_preview = 'gpt-4-0125-preview'
    gpt_4_turbo_preview = 'gpt-4-turbo-preview'
    gpt_4_1106_preview = 'gpt-4-1106-preview'
    gpt_4_vision_preview = 'gpt-4-vision-preview'
    gpt_4 = 'gpt-4'
    gpt_4_0314 = 'gpt-4-0314'
    gpt_4_0613 = 'gpt-4-0613'
    gpt_4_32k = 'gpt-4-32k'
    gpt_4_32k_0314 = 'gpt-4-32k-0314'
    gpt_4_32k_0613 = 'gpt-4-32k-0613'
    gpt_3_5_turbo = 'gpt-3.5-turbo'
    gpt_3_5_turbo_16k = 'gpt-3.5-turbo-16k'
    gpt_3_5_turbo_0613 = 'gpt-3.5-turbo-0613'
    gpt_3_5_turbo_1106 = 'gpt-3.5-turbo-1106'
    gpt_3_5_turbo_0125 = 'gpt-3.5-turbo-0125'
    gpt_3_5_turbo_16k_0613 = 'gpt-3.5-turbo-16k-0613'


class CodeInterpreter1(BaseModel):
    file_ids: List[str] = Field([], max_length=20)
    """
    A list of [file](/docs/api-reference/files) IDs made available to the `code_interpreter` tool. There can be a maximum of 20 files associated with the tool.

    """


class ChunkingStrategy(AutoChunkingStrategyRequestParam):
    """
    The default strategy. This strategy currently uses a `max_chunk_size_tokens` of `800` and `chunk_overlap_tokens` of `400`.
    """


class Type17(str, Enum):
    """
    Always `static`.
    """

    static = 'static'


class Static(BaseModel):
    model_config = ConfigDict(
        extra='forbid',
    )
    max_chunk_size_tokens: int = Field(..., ge=100, le=4096)
    """
    The maximum number of tokens in each chunk. The default value is `800`. The minimum value is `100` and the maximum value is `4096`.
    """
    chunk_overlap_tokens: int
    """
    The number of tokens that overlap between chunks. The default value is `400`.

    Note that the overlap must not exceed half of `max_chunk_size_tokens`.

    """


class ChunkingStrategy1(BaseModel):
    """
    The chunking strategy used to chunk the file(s). If not set, will use the `auto` strategy.
    """

    model_config = ConfigDict(
        extra='forbid',
    )
    type: Type17
    """
    Always `static`.
    """
    static: Static


class VectorStore(BaseModel):
    file_ids: Optional[List[str]] = Field(None, max_length=10000)
    """
    A list of [file](/docs/api-reference/files) IDs to add to the vector store. There can be a maximum of 10000 files in a vector store.

    """
    chunking_strategy: Optional[Union[ChunkingStrategy, ChunkingStrategy1]] = None
    """
    The chunking strategy used to chunk the file(s). If not set, will use the `auto` strategy.
    """
    metadata: Optional[Dict[str, Any]] = None
    """
    Set of 16 key-value pairs that can be attached to a vector store. This can be useful for storing additional information about the vector store in a structured format. Keys can be a maximum of 64 characters long and values can be a maximum of 512 characters long.

    """


class FileSearch2(BaseModel):
    vector_store_ids: List[str] = Field(..., max_length=1)
    """
    The [vector store](/docs/api-reference/vector-stores/object) attached to this assistant. There can be a maximum of 1 vector store attached to the assistant.

    """
    vector_stores: Optional[List[VectorStore]] = Field(None, max_length=1)
    """
    A helper to create a [vector store](/docs/api-reference/vector-stores/object) with file_ids and attach it to this assistant. There can be a maximum of 1 vector store attached to the assistant.

    """


class ChunkingStrategy2(AutoChunkingStrategyRequestParam):
    """
    The default strategy. This strategy currently uses a `max_chunk_size_tokens` of `800` and `chunk_overlap_tokens` of `400`.
    """


class ChunkingStrategy3(ChunkingStrategy1):
    """
    The chunking strategy used to chunk the file(s). If not set, will use the `auto` strategy.
    """


class VectorStore1(BaseModel):
    file_ids: Optional[List[str]] = Field(None, max_length=10000)
    """
    A list of [file](/docs/api-reference/files) IDs to add to the vector store. There can be a maximum of 10000 files in a vector store.

    """
    chunking_strategy: Optional[Union[ChunkingStrategy2, ChunkingStrategy3]] = None
    """
    The chunking strategy used to chunk the file(s). If not set, will use the `auto` strategy.
    """
    metadata: Optional[Dict[str, Any]] = None
    """
    Set of 16 key-value pairs that can be attached to a vector store. This can be useful for storing additional information about the vector store in a structured format. Keys can be a maximum of 64 characters long and values can be a maximum of 512 characters long.

    """


class FileSearch3(BaseModel):
    vector_store_ids: Optional[List[str]] = Field(None, max_length=1)
    """
    The [vector store](/docs/api-reference/vector-stores/object) attached to this assistant. There can be a maximum of 1 vector store attached to the assistant.

    """
    vector_stores: List[VectorStore1] = Field(..., max_length=1)
    """
    A helper to create a [vector store](/docs/api-reference/vector-stores/object) with file_ids and attach it to this assistant. There can be a maximum of 1 vector store attached to the assistant.

    """


class ToolResources1(BaseModel):
    """
    A set of resources that are used by the assistant's tools. The resources are specific to the type of tool. For example, the `code_interpreter` tool requires a list of file IDs, while the `file_search` tool requires a list of vector store IDs.

    """

    code_interpreter: Optional[CodeInterpreter1] = None
    file_search: Optional[Union[FileSearch2, FileSearch3]] = None


class FinishReason(str, Enum):
    """
    The reason the model stopped generating tokens. This will be `stop` if the model hit a natural stop point or a provided stop sequence, `length` if the maximum number of tokens specified in the request was reached, `content_filter` if content was omitted due to a flag from our content filters, or `function_call` if the model called a function.

    """

    stop = 'stop'
    length = 'length'
    function_call = 'function_call'
    content_filter = 'content_filter'


class Choice(BaseModel):
    finish_reason: FinishReason
    """
    The reason the model stopped generating tokens. This will be `stop` if the model hit a natural stop point or a provided stop sequence, `length` if the maximum number of tokens specified in the request was reached, `content_filter` if content was omitted due to a flag from our content filters, or `function_call` if the model called a function.

    """
    index: int
    """
    The index of the choice in the list of choices.
    """
    message: ChatCompletionResponseMessage


class Object2(str, Enum):
    """
    The object type, which is always `chat.completion`.
    """

    chat_completion = 'chat.completion'


class CreateChatCompletionFunctionResponse(BaseModel):
    """
    Represents a chat completion response returned by model, based on the provided input.
    """

    id: str
    """
    A unique identifier for the chat completion.
    """
    choices: List[Choice]
    """
    A list of chat completion choices. Can be more than one if `n` is greater than 1.
    """
    created: int
    """
    The Unix timestamp (in seconds) of when the chat completion was created.
    """
    model: str
    """
    The model used for the chat completion.
    """
    system_fingerprint: Optional[str] = None
    """
    This fingerprint represents the backend configuration that the model runs with.

    Can be used in conjunction with the `seed` request parameter to understand when backend changes have been made that might impact determinism.

    """
    object: Object2
    """
    The object type, which is always `chat.completion`.
    """
    usage: Optional[CompletionUsage] = None


class CreateChatCompletionImageResponse(BaseModel):
    """
    Represents a streamed chunk of a chat completion response returned by model, based on the provided input.
    """


class Model1(str, Enum):
    """
    ID of the model to use. See the [model endpoint compatibility](/docs/models/model-endpoint-compatibility) table for details on which models work with the Chat API.
    """

    o1_preview = 'o1-preview'
    o1_preview_2024_09_12 = 'o1-preview-2024-09-12'
    o1_mini = 'o1-mini'
    o1_mini_2024_09_12 = 'o1-mini-2024-09-12'
    gpt_4o = 'gpt-4o'
    gpt_4o_2024_08_06 = 'gpt-4o-2024-08-06'
    gpt_4o_2024_05_13 = 'gpt-4o-2024-05-13'
    gpt_4o_2024_08_06_1 = 'gpt-4o-2024-08-06'
    gpt_4o_realtime_preview = 'gpt-4o-realtime-preview'
    gpt_4o_realtime_preview_2024_10_01 = 'gpt-4o-realtime-preview-2024-10-01'
    gpt_4o_audio_preview = 'gpt-4o-audio-preview'
    gpt_4o_audio_preview_2024_10_01 = 'gpt-4o-audio-preview-2024-10-01'
    chatgpt_4o_latest = 'chatgpt-4o-latest'
    gpt_4o_mini = 'gpt-4o-mini'
    gpt_4o_mini_2024_07_18 = 'gpt-4o-mini-2024-07-18'
    gpt_4_turbo = 'gpt-4-turbo'
    gpt_4_turbo_2024_04_09 = 'gpt-4-turbo-2024-04-09'
    gpt_4_0125_preview = 'gpt-4-0125-preview'
    gpt_4_turbo_preview = 'gpt-4-turbo-preview'
    gpt_4_1106_preview = 'gpt-4-1106-preview'
    gpt_4_vision_preview = 'gpt-4-vision-preview'
    gpt_4 = 'gpt-4'
    gpt_4_0314 = 'gpt-4-0314'
    gpt_4_0613 = 'gpt-4-0613'
    gpt_4_32k = 'gpt-4-32k'
    gpt_4_32k_0314 = 'gpt-4-32k-0314'
    gpt_4_32k_0613 = 'gpt-4-32k-0613'
    gpt_3_5_turbo = 'gpt-3.5-turbo'
    gpt_3_5_turbo_16k = 'gpt-3.5-turbo-16k'
    gpt_3_5_turbo_0301 = 'gpt-3.5-turbo-0301'
    gpt_3_5_turbo_0613 = 'gpt-3.5-turbo-0613'
    gpt_3_5_turbo_1106 = 'gpt-3.5-turbo-1106'
    gpt_3_5_turbo_0125 = 'gpt-3.5-turbo-0125'
    gpt_3_5_turbo_16k_0613 = 'gpt-3.5-turbo-16k-0613'


class Voice(str, Enum):
    """
    Specifies the voice type. Supported voices are `alloy`, `echo`,
    `fable`, `onyx`, `nova`, and `shimmer`.

    """

    alloy = 'alloy'
    echo = 'echo'
    fable = 'fable'
    onyx = 'onyx'
    nova = 'nova'
    shimmer = 'shimmer'


class Format1(str, Enum):
    """
    Specifies the output audio format. Must be one of `wav`, `mp3`, `flac`,
    `opus`, or `pcm16`.

    """

    wav = 'wav'
    mp3 = 'mp3'
    flac = 'flac'
    opus = 'opus'
    pcm16 = 'pcm16'


class Audio2(BaseModel):
    """
    Parameters for audio output. Required when audio output is requested with
    `modalities: ["audio"]`. [Learn more](/docs/guides/audio).

    """

    voice: Voice
    """
    Specifies the voice type. Supported voices are `alloy`, `echo`, 
    `fable`, `onyx`, `nova`, and `shimmer`.

    """
    format: Format1
    """
    Specifies the output audio format. Must be one of `wav`, `mp3`, `flac`,
    `opus`, or `pcm16`. 

    """


class ServiceTier(str, Enum):
    """
    Specifies the latency tier to use for processing the request. This parameter is relevant for customers subscribed to the scale tier service:
      - If set to 'auto', and the Project is Scale tier enabled, the system will utilize scale tier credits until they are exhausted.
      - If set to 'auto', and the Project is not Scale tier enabled, the request will be processed using the default service tier with a lower uptime SLA and no latency guarentee.
      - If set to 'default', the request will be processed using the default service tier with a lower uptime SLA and no latency guarentee.
      - When not set, the default behavior is 'auto'.

      When this parameter is set, the response body will include the `service_tier` utilized.

    """

    auto = 'auto'
    default = 'default'


class Stop(RootModel[List[str]]):
    root: List[str] = Field(..., max_length=4, min_length=1)
    """
    Up to 4 sequences where the API will stop generating further tokens.

    """


class FunctionCall3(str, Enum):
    """
    `none` means the model will not call a function and instead generates a message. `auto` means the model can pick between generating a message or calling a function.

    """

    none = 'none'
    auto = 'auto'


class FinishReason1(str, Enum):
    """
    The reason the model stopped generating tokens. This will be `stop` if the model hit a natural stop point or a provided stop sequence,
    `length` if the maximum number of tokens specified in the request was reached,
    `content_filter` if content was omitted due to a flag from our content filters,
    `tool_calls` if the model called a tool, or `function_call` (deprecated) if the model called a function.

    """

    stop = 'stop'
    length = 'length'
    tool_calls = 'tool_calls'
    content_filter = 'content_filter'
    function_call = 'function_call'


class Logprobs(BaseModel):
    """
    Log probability information for the choice.
    """

    content: Optional[List[ChatCompletionTokenLogprob]] = Field(None)
    """
    A list of message content tokens with log probability information.
    """
    refusal: Optional[List[ChatCompletionTokenLogprob]] = Field(None)
    """
    A list of message refusal tokens with log probability information.
    """


class Choice1(BaseModel):
    finish_reason: FinishReason1
    """
    The reason the model stopped generating tokens. This will be `stop` if the model hit a natural stop point or a provided stop sequence,
    `length` if the maximum number of tokens specified in the request was reached,
    `content_filter` if content was omitted due to a flag from our content filters,
    `tool_calls` if the model called a tool, or `function_call` (deprecated) if the model called a function.

    """
    index: int
    """
    The index of the choice in the list of choices.
    """
    message: ChatCompletionResponseMessage
    logprobs: Optional[Logprobs] = Field(None)
    """
    Log probability information for the choice.
    """


class ServiceTier1(str, Enum):
    """
    The service tier used for processing the request. This field is only included if the `service_tier` parameter is specified in the request.
    """

    scale = 'scale'
    default = 'default'


class CreateChatCompletionResponse(BaseModel):
    """
    Represents a chat completion response returned by model, based on the provided input.
    """

    id: str
    """
    A unique identifier for the chat completion.
    """
    choices: List[Choice1]
    """
    A list of chat completion choices. Can be more than one if `n` is greater than 1.
    """
    created: int
    """
    The Unix timestamp (in seconds) of when the chat completion was created.
    """
    model: str
    """
    The model used for the chat completion.
    """
    service_tier: Optional[ServiceTier1] = Field(None, examples=['scale'])
    """
    The service tier used for processing the request. This field is only included if the `service_tier` parameter is specified in the request.
    """
    system_fingerprint: Optional[str] = None
    """
    This fingerprint represents the backend configuration that the model runs with.

    Can be used in conjunction with the `seed` request parameter to understand when backend changes have been made that might impact determinism.

    """
    object: Object2
    """
    The object type, which is always `chat.completion`.
    """
    usage: Optional[CompletionUsage] = None


class Choice2(BaseModel):
    delta: ChatCompletionStreamResponseDelta
    logprobs: Optional[Logprobs] = None
    """
    Log probability information for the choice.
    """
    finish_reason: Optional[FinishReason1] = Field(None)
    """
    The reason the model stopped generating tokens. This will be `stop` if the model hit a natural stop point or a provided stop sequence,
    `length` if the maximum number of tokens specified in the request was reached,
    `content_filter` if content was omitted due to a flag from our content filters,
    `tool_calls` if the model called a tool, or `function_call` (deprecated) if the model called a function.

    """
    index: int
    """
    The index of the choice in the list of choices.
    """


class Object4(str, Enum):
    """
    The object type, which is always `chat.completion.chunk`.
    """

    chat_completion_chunk = 'chat.completion.chunk'


class Usage(BaseModel):
    """
    An optional field that will only be present when you set `stream_options: {"include_usage": true}` in your request.
    When present, it contains a null value except for the last chunk which contains the token usage statistics for the entire request.

    """

    completion_tokens: int
    """
    Number of tokens in the generated completion.
    """
    prompt_tokens: int
    """
    Number of tokens in the prompt.
    """
    total_tokens: int
    """
    Total number of tokens used in the request (prompt + completion).
    """


class CreateChatCompletionStreamResponse(BaseModel):
    """
    Represents a streamed chunk of a chat completion response returned by model, based on the provided input.
    """

    id: str
    """
    A unique identifier for the chat completion. Each chunk has the same ID.
    """
    choices: List[Choice2]
    """
    A list of chat completion choices. Can contain more than one elements if `n` is greater than 1. Can also be empty for the
    last chunk if you set `stream_options: {"include_usage": true}`.

    """
    created: int
    """
    The Unix timestamp (in seconds) of when the chat completion was created. Each chunk has the same timestamp.
    """
    model: str
    """
    The model to generate the completion.
    """
    service_tier: Optional[ServiceTier1] = Field(None, examples=['scale'])
    """
    The service tier used for processing the request. This field is only included if the `service_tier` parameter is specified in the request.
    """
    system_fingerprint: Optional[str] = None
    """
    This fingerprint represents the backend configuration that the model runs with.
    Can be used in conjunction with the `seed` request parameter to understand when backend changes have been made that might impact determinism.

    """
    object: Object4
    """
    The object type, which is always `chat.completion.chunk`.
    """
    usage: Optional[Usage] = None
    """
    An optional field that will only be present when you set `stream_options: {"include_usage": true}` in your request.
    When present, it contains a null value except for the last chunk which contains the token usage statistics for the entire request.

    """


class Model2(str, Enum):
    """
    ID of the model to use. You can use the [List models](/docs/api-reference/models/list) API to see all of your available models, or see our [Model overview](/docs/models/overview) for descriptions of them.

    """

    gpt_3_5_turbo_instruct = 'gpt-3.5-turbo-instruct'
    davinci_002 = 'davinci-002'
    babbage_002 = 'babbage-002'


class Prompt(RootModel[Optional[List[int]]]):
    root: Optional[List[int]] = Field(
        '<|endoftext|>', examples=['[1212, 318, 257, 1332, 13]'], min_length=1
    )
    """
    The prompt(s) to generate completions for, encoded as a string, array of strings, array of tokens, or array of token arrays.

    Note that <|endoftext|> is the document separator that the model sees during training, so if a prompt is not specified the model will generate as if from the beginning of a new document.

    """


class Prompt1Item(RootModel[List[int]]):
    root: List[int] = Field(..., min_length=1)


class Prompt1(RootModel[Optional[List[Prompt1Item]]]):
    root: Optional[List[Prompt1Item]] = Field(
        '<|endoftext|>', examples=['[[1212, 318, 257, 1332, 13]]'], min_length=1
    )
    """
    The prompt(s) to generate completions for, encoded as a string, array of strings, array of tokens, or array of token arrays.

    Note that <|endoftext|> is the document separator that the model sees during training, so if a prompt is not specified the model will generate as if from the beginning of a new document.

    """


class Stop1(RootModel[Optional[List[str]]]):
    root: Optional[List[str]] = Field(None, max_length=4, min_length=1)
    """
    Up to 4 sequences where the API will stop generating further tokens. The returned text will not contain the stop sequence.

    """


class CreateCompletionRequest(BaseModel):
    model: Union[str, Model2]
    """
    ID of the model to use. You can use the [List models](/docs/api-reference/models/list) API to see all of your available models, or see our [Model overview](/docs/models/overview) for descriptions of them.

    """
    prompt: Optional[Union[Optional[str], List[str], Prompt, Prompt1]] = Field(None)
    """
    The prompt(s) to generate completions for, encoded as a string, array of strings, array of tokens, or array of token arrays.

    Note that <|endoftext|> is the document separator that the model sees during training, so if a prompt is not specified the model will generate as if from the beginning of a new document.

    """
    best_of: Optional[int] = Field(1, ge=0, le=20)
    """
    Generates `best_of` completions server-side and returns the "best" (the one with the highest log probability per token). Results cannot be streamed.

    When used with `n`, `best_of` controls the number of candidate completions and `n` specifies how many to return – `best_of` must be greater than `n`.

    **Note:** Because this parameter generates many completions, it can quickly consume your token quota. Use carefully and ensure that you have reasonable settings for `max_tokens` and `stop`.

    """
    echo: Optional[bool] = False
    """
    Echo back the prompt in addition to the completion

    """
    frequency_penalty: Optional[float] = Field(0, ge=-2.0, le=2.0)
    """
    Number between -2.0 and 2.0. Positive values penalize new tokens based on their existing frequency in the text so far, decreasing the model's likelihood to repeat the same line verbatim.

    [See more information about frequency and presence penalties.](/docs/guides/text-generation/parameter-details)

    """
    logit_bias: Optional[Dict[str, int]] = None
    """
    Modify the likelihood of specified tokens appearing in the completion.

    Accepts a JSON object that maps tokens (specified by their token ID in the GPT tokenizer) to an associated bias value from -100 to 100. You can use this [tokenizer tool](/tokenizer?view=bpe) to convert text to token IDs. Mathematically, the bias is added to the logits generated by the model prior to sampling. The exact effect will vary per model, but values between -1 and 1 should decrease or increase likelihood of selection; values like -100 or 100 should result in a ban or exclusive selection of the relevant token.

    As an example, you can pass `{"50256": -100}` to prevent the <|endoftext|> token from being generated.

    """
    logprobs: Optional[int] = Field(None, ge=0, le=5)
    """
    Include the log probabilities on the `logprobs` most likely output tokens, as well the chosen tokens. For example, if `logprobs` is 5, the API will return a list of the 5 most likely tokens. The API will always return the `logprob` of the sampled token, so there may be up to `logprobs+1` elements in the response.

    The maximum value for `logprobs` is 5.

    """
    max_tokens: Optional[int] = Field(16, examples=[16], ge=0)
    """
    The maximum number of [tokens](/tokenizer) that can be generated in the completion.

    The token count of your prompt plus `max_tokens` cannot exceed the model's context length. [Example Python code](https://cookbook.openai.com/examples/how_to_count_tokens_with_tiktoken) for counting tokens.

    """
    n: Optional[int] = Field(1, examples=[1], ge=1, le=128)
    """
    How many completions to generate for each prompt.

    **Note:** Because this parameter generates many completions, it can quickly consume your token quota. Use carefully and ensure that you have reasonable settings for `max_tokens` and `stop`.

    """
    presence_penalty: Optional[float] = Field(0, ge=-2.0, le=2.0)
    """
    Number between -2.0 and 2.0. Positive values penalize new tokens based on whether they appear in the text so far, increasing the model's likelihood to talk about new topics.

    [See more information about frequency and presence penalties.](/docs/guides/text-generation/parameter-details)

    """
    seed: Optional[int] = Field(None, ge=-9223372036854776000, le=9223372036854776000)
    """
    If specified, our system will make a best effort to sample deterministically, such that repeated requests with the same `seed` and parameters should return the same result.

    Determinism is not guaranteed, and you should refer to the `system_fingerprint` response parameter to monitor changes in the backend.

    """
    stop: Optional[Union[Optional[str], Stop1]] = None
    """
    Up to 4 sequences where the API will stop generating further tokens. The returned text will not contain the stop sequence.

    """
    stream: Optional[bool] = False
    """
    Whether to stream back partial progress. If set, tokens will be sent as data-only [server-sent events](https://developer.mozilla.org/en-US/docs/Web/API/Server-sent_events/Using_server-sent_events#Event_stream_format) as they become available, with the stream terminated by a `data: [DONE]` message. [Example Python code](https://cookbook.openai.com/examples/how_to_stream_completions).

    """
    stream_options: Optional[ChatCompletionStreamOptions] = None
    suffix: Optional[str] = Field(None, examples=['test.'])
    """
    The suffix that comes after a completion of inserted text.

    This parameter is only supported for `gpt-3.5-turbo-instruct`.

    """
    temperature: Optional[float] = Field(1, examples=[1], ge=0.0, le=2.0)
    """
    What sampling temperature to use, between 0 and 2. Higher values like 0.8 will make the output more random, while lower values like 0.2 will make it more focused and deterministic.

    We generally recommend altering this or `top_p` but not both.

    """
    top_p: Optional[float] = Field(1, examples=[1], ge=0.0, le=1.0)
    """
    An alternative to sampling with temperature, called nucleus sampling, where the model considers the results of the tokens with top_p probability mass. So 0.1 means only the tokens comprising the top 10% probability mass are considered.

    We generally recommend altering this or `temperature` but not both.

    """
    user: Optional[str] = Field(None, examples=['user-1234'])
    """
    A unique identifier representing your end-user, which can help OpenAI to monitor and detect abuse. [Learn more](/docs/guides/safety-best-practices/end-user-ids).

    """


class FinishReason3(str, Enum):
    """
    The reason the model stopped generating tokens. This will be `stop` if the model hit a natural stop point or a provided stop sequence,
    `length` if the maximum number of tokens specified in the request was reached,
    or `content_filter` if content was omitted due to a flag from our content filters.

    """

    stop = 'stop'
    length = 'length'
    content_filter = 'content_filter'


class Logprobs2(BaseModel):
    text_offset: Optional[List[int]] = None
    token_logprobs: Optional[List[float]] = None
    tokens: Optional[List[str]] = None
    top_logprobs: Optional[List[Dict[str, float]]] = None


class Choice3(BaseModel):
    finish_reason: Optional[FinishReason3] = None
    """
    The reason the model stopped generating tokens. This will be `stop` if the model hit a natural stop point or a provided stop sequence,
    `length` if the maximum number of tokens specified in the request was reached,
    or `content_filter` if content was omitted due to a flag from our content filters.

    """
    index: int
    logprobs: Optional[Logprobs2] = Field(None)
    text: str


class Object5(str, Enum):
    """
    The object type, which is always "text_completion"
    """

    text_completion = 'text_completion'


class CreateCompletionResponse(BaseModel):
    """
    Represents a completion response from the API. Note: both the streamed and non-streamed response objects share the same shape (unlike the chat endpoint).

    """

    id: str
    """
    A unique identifier for the completion.
    """
    choices: List[Choice3]
    """
    The list of completion choices the model generated for the input prompt.
    """
    created: int
    """
    The Unix timestamp (in seconds) of when the completion was created.
    """
    model: str
    """
    The model used for completion.
    """
    system_fingerprint: Optional[str] = None
    """
    This fingerprint represents the backend configuration that the model runs with.

    Can be used in conjunction with the `seed` request parameter to understand when backend changes have been made that might impact determinism.

    """
    object: Object5
    """
    The object type, which is always "text_completion"
    """
    usage: Optional[CompletionUsage] = None


class Input(RootModel[List[str]]):
    root: List[str] = Field(
        ...,
        examples=['The quick brown fox jumped over the lazy dog'],
        max_length=2048,
        min_length=1,
        title='array',
    )
    """
    The array of strings that will be turned into an embedding.
    """


class Input1(RootModel[List[int]]):
    root: List[int] = Field(
        ...,
        examples=['[1212, 318, 257, 1332, 13]'],
        max_length=2048,
        min_length=1,
        title='array',
    )
    """
    The array of integers that will be turned into an embedding.
    """


class Input2Item(Prompt1Item):
    pass


class Input2(RootModel[List[Input2Item]]):
    root: List[Input2Item] = Field(
        ...,
        examples=['[[1212, 318, 257, 1332, 13]]'],
        max_length=2048,
        min_length=1,
        title='array',
    )
    """
    The array of arrays containing integers that will be turned into an embedding.
    """


class Model3(str, Enum):
    """
    ID of the model to use. You can use the [List models](/docs/api-reference/models/list) API to see all of your available models, or see our [Model overview](/docs/models/overview) for descriptions of them.

    """

    text_embedding_ada_002 = 'text-embedding-ada-002'
    text_embedding_3_small = 'text-embedding-3-small'
    text_embedding_3_large = 'text-embedding-3-large'


class EncodingFormat(str, Enum):
    """
    The format to return the embeddings in. Can be either `float` or [`base64`](https://pypi.org/project/pybase64/).
    """

    float = 'float'
    base64 = 'base64'


class CreateEmbeddingRequest(BaseModel):
    model_config = ConfigDict(
        extra='forbid',
    )
    input: Union[str, Input, Input1, Input2] = Field(
        ..., examples=['The quick brown fox jumped over the lazy dog']
    )
    """
    Input text to embed, encoded as a string or array of tokens. To embed multiple inputs in a single request, pass an array of strings or array of token arrays. The input must not exceed the max input tokens for the model (8192 tokens for `text-embedding-ada-002`), cannot be an empty string, and any array must be 2048 dimensions or less. [Example Python code](https://cookbook.openai.com/examples/how_to_count_tokens_with_tiktoken) for counting tokens.

    """
    model: Union[str, Model3] = Field(..., examples=['text-embedding-3-small'])
    """
    ID of the model to use. You can use the [List models](/docs/api-reference/models/list) API to see all of your available models, or see our [Model overview](/docs/models/overview) for descriptions of them.

    """
    encoding_format: EncodingFormat = Field('float', examples=['float'])
    """
    The format to return the embeddings in. Can be either `float` or [`base64`](https://pypi.org/project/pybase64/).
    """
    dimensions: Optional[int] = Field(None, ge=1)
    """
    The number of dimensions the resulting output embeddings should have. Only supported in `text-embedding-3` and later models.

    """
    user: Optional[str] = Field(None, examples=['user-1234'])
    """
    A unique identifier representing your end-user, which can help OpenAI to monitor and detect abuse. [Learn more](/docs/guides/safety-best-practices/end-user-ids).

    """


class Object6(str, Enum):
    """
    The object type, which is always "list".
    """

    list = 'list'


class Usage1(BaseModel):
    """
    The usage information for the request.
    """

    prompt_tokens: int
    """
    The number of tokens used by the prompt.
    """
    total_tokens: int
    """
    The total number of tokens used by the request.
    """


class Purpose(str, Enum):
    """
    The intended purpose of the uploaded file.

    Use "assistants" for [Assistants](/docs/api-reference/assistants) and [Message](/docs/api-reference/messages) files, "vision" for Assistants image file inputs, "batch" for [Batch API](/docs/guides/batch), and "fine-tune" for [Fine-tuning](/docs/api-reference/fine-tuning).

    """

    assistants = 'assistants'
    batch = 'batch'
    fine_tune = 'fine-tune'
    vision = 'vision'


class CreateFileRequest(BaseModel):
    model_config = ConfigDict(
        extra='forbid',
    )
    file: bytes
    """
    The File object (not file name) to be uploaded.

    """
    purpose: Purpose
    """
    The intended purpose of the uploaded file.

    Use "assistants" for [Assistants](/docs/api-reference/assistants) and [Message](/docs/api-reference/messages) files, "vision" for Assistants image file inputs, "batch" for [Batch API](/docs/guides/batch), and "fine-tune" for [Fine-tuning](/docs/api-reference/fine-tuning).

    """


class Model4(str, Enum):
    """
    The name of the model to fine-tune. You can select one of the
    [supported models](/docs/guides/fine-tuning/which-models-can-be-fine-tuned).

    """

    babbage_002 = 'babbage-002'
    davinci_002 = 'davinci-002'
    gpt_3_5_turbo = 'gpt-3.5-turbo'
    gpt_4o_mini = 'gpt-4o-mini'


class BatchSize(str, Enum):
    """
    Number of examples in each batch. A larger batch size means that model parameters
    are updated less frequently, but with lower variance.

    """

    auto = 'auto'


class BatchSize1(RootModel[int]):
    root: int = Field(..., ge=1, le=256)
    """
    Number of examples in each batch. A larger batch size means that model parameters
    are updated less frequently, but with lower variance.

    """


class LearningRateMultiplier(str, Enum):
    """
    Scaling factor for the learning rate. A smaller learning rate may be useful to avoid
    overfitting.

    """

    auto = 'auto'


class LearningRateMultiplier1(RootModel[float]):
    root: float = Field(..., gt=0.0)
    """
    Scaling factor for the learning rate. A smaller learning rate may be useful to avoid
    overfitting.

    """


class NEpochs(str, Enum):
    """
    The number of epochs to train the model for. An epoch refers to one full cycle
    through the training dataset.

    """

    auto = 'auto'


class NEpochs1(RootModel[int]):
    root: int = Field(..., ge=1, le=50)
    """
    The number of epochs to train the model for. An epoch refers to one full cycle
    through the training dataset.

    """


class Hyperparameters(BaseModel):
    """
    The hyperparameters used for the fine-tuning job.
    """

    batch_size: Union[BatchSize, BatchSize1] = 'auto'
    """
    Number of examples in each batch. A larger batch size means that model parameters
    are updated less frequently, but with lower variance.

    """
    learning_rate_multiplier: Union[LearningRateMultiplier, LearningRateMultiplier1] = (
        'auto'
    )
    """
    Scaling factor for the learning rate. A smaller learning rate may be useful to avoid
    overfitting.

    """
    n_epochs: Union[NEpochs, NEpochs1] = 'auto'
    """
    The number of epochs to train the model for. An epoch refers to one full cycle
    through the training dataset.

    """


class Type20(str, Enum):
    """
    The type of integration to enable. Currently, only "wandb" (Weights and Biases) is supported.

    """

    wandb = 'wandb'


class Wandb(BaseModel):
    """
    The settings for your integration with Weights and Biases. This payload specifies the project that
    metrics will be sent to. Optionally, you can set an explicit display name for your run, add tags
    to your run, and set a default entity (team, username, etc) to be associated with your run.

    """

    project: str = Field(..., examples=['my-wandb-project'])
    """
    The name of the project that the new run will be created under.

    """
    name: Optional[str] = None
    """
    A display name to set for the run. If not set, we will use the Job ID as the name.

    """
    entity: Optional[str] = None
    """
    The entity to use for the run. This allows you to set the team or username of the WandB user that you would
    like associated with the run. If not set, the default entity for the registered WandB API key is used.

    """
    tags: Optional[List[str]] = None
    """
    A list of tags to be attached to the newly created run. These tags are passed through directly to WandB. Some
    default tags are generated by OpenAI: "openai/finetune", "openai/{base-model}", "openai/{ftjob-abcdef}".

    """


class Integration(BaseModel):
    type: Type20
    """
    The type of integration to enable. Currently, only "wandb" (Weights and Biases) is supported.

    """
    wandb: Wandb
    """
    The settings for your integration with Weights and Biases. This payload specifies the project that
    metrics will be sent to. Optionally, you can set an explicit display name for your run, add tags
    to your run, and set a default entity (team, username, etc) to be associated with your run.

    """


class CreateFineTuningJobRequest(BaseModel):
    model: Union[str, Model4] = Field(..., examples=['gpt-4o-mini'])
    """
    The name of the model to fine-tune. You can select one of the
    [supported models](/docs/guides/fine-tuning/which-models-can-be-fine-tuned).

    """
    training_file: str = Field(..., examples=['file-abc123'])
    """
    The ID of an uploaded file that contains training data.

    See [upload file](/docs/api-reference/files/create) for how to upload a file.

    Your dataset must be formatted as a JSONL file. Additionally, you must upload your file with the purpose `fine-tune`.

    The contents of the file should differ depending on if the model uses the [chat](/docs/api-reference/fine-tuning/chat-input) or [completions](/docs/api-reference/fine-tuning/completions-input) format.

    See the [fine-tuning guide](/docs/guides/fine-tuning) for more details.

    """
    hyperparameters: Optional[Hyperparameters] = None
    """
    The hyperparameters used for the fine-tuning job.
    """
    suffix: Optional[str] = Field(None, max_length=64, min_length=1)
    """
    A string of up to 64 characters that will be added to your fine-tuned model name.

    For example, a `suffix` of "custom-model-name" would produce a model name like `ft:gpt-4o-mini:openai:custom-model-name:7p4lURel`.

    """
    validation_file: Optional[str] = Field(None, examples=['file-abc123'])
    """
    The ID of an uploaded file that contains validation data.

    If you provide this file, the data is used to generate validation
    metrics periodically during fine-tuning. These metrics can be viewed in
    the fine-tuning results file.
    The same data should not be present in both train and validation files.

    Your dataset must be formatted as a JSONL file. You must upload your file with the purpose `fine-tune`.

    See the [fine-tuning guide](/docs/guides/fine-tuning) for more details.

    """
    integrations: Optional[List[Integration]] = None
    """
    A list of integrations to enable for your fine-tuning job.
    """
    seed: Optional[int] = Field(None, examples=[42], ge=0, le=2147483647)
    """
    The seed controls the reproducibility of the job. Passing in the same seed and job parameters should produce the same results, but may differ in rare cases.
    If a seed is not specified, one will be generated for you.

    """


class Model5(str, Enum):
    """
    The model to use for image generation. Only `dall-e-2` is supported at this time.
    """

    dall_e_2 = 'dall-e-2'


class Size(str, Enum):
    """
    The size of the generated images. Must be one of `256x256`, `512x512`, or `1024x1024`.
    """

    field_256x256 = '256x256'
    field_512x512 = '512x512'
    field_1024x1024 = '1024x1024'


class ResponseFormat(str, Enum):
    """
    The format in which the generated images are returned. Must be one of `url` or `b64_json`. URLs are only valid for 60 minutes after the image has been generated.
    """

    url = 'url'
    b64_json = 'b64_json'


class CreateImageEditRequest(BaseModel):
    image: bytes
    """
    The image to edit. Must be a valid PNG file, less than 4MB, and square. If mask is not provided, image must have transparency, which will be used as the mask.
    """
    prompt: str = Field(..., examples=['A cute baby sea otter wearing a beret'])
    """
    A text description of the desired image(s). The maximum length is 1000 characters.
    """
    mask: Optional[bytes] = None
    """
    An additional image whose fully transparent areas (e.g. where alpha is zero) indicate where `image` should be edited. Must be a valid PNG file, less than 4MB, and have the same dimensions as `image`.
    """
    model: Optional[Union[Optional[str], Model5]] = Field(
        'dall-e-2', examples=['dall-e-2']
    )
    """
    The model to use for image generation. Only `dall-e-2` is supported at this time.
    """
    n: Optional[int] = Field(1, examples=[1], ge=1, le=10)
    """
    The number of images to generate. Must be between 1 and 10.
    """
    size: Optional[Size] = Field('1024x1024', examples=['1024x1024'])
    """
    The size of the generated images. Must be one of `256x256`, `512x512`, or `1024x1024`.
    """
    response_format: Optional[ResponseFormat] = Field('url', examples=['url'])
    """
    The format in which the generated images are returned. Must be one of `url` or `b64_json`. URLs are only valid for 60 minutes after the image has been generated.
    """
    user: Optional[str] = Field(None, examples=['user-1234'])
    """
    A unique identifier representing your end-user, which can help OpenAI to monitor and detect abuse. [Learn more](/docs/guides/safety-best-practices/end-user-ids).

    """


class Model6(str, Enum):
    """
    The model to use for image generation.
    """

    dall_e_2 = 'dall-e-2'
    dall_e_3 = 'dall-e-3'


class Quality(str, Enum):
    """
    The quality of the image that will be generated. `hd` creates images with finer details and greater consistency across the image. This param is only supported for `dall-e-3`.
    """

    standard = 'standard'
    hd = 'hd'


class Size1(str, Enum):
    """
    The size of the generated images. Must be one of `256x256`, `512x512`, or `1024x1024` for `dall-e-2`. Must be one of `1024x1024`, `1792x1024`, or `1024x1792` for `dall-e-3` models.
    """

    field_256x256 = '256x256'
    field_512x512 = '512x512'
    field_1024x1024 = '1024x1024'
    field_1792x1024 = '1792x1024'
    field_1024x1792 = '1024x1792'


class Style(str, Enum):
    """
    The style of the generated images. Must be one of `vivid` or `natural`. Vivid causes the model to lean towards generating hyper-real and dramatic images. Natural causes the model to produce more natural, less hyper-real looking images. This param is only supported for `dall-e-3`.
    """

    vivid = 'vivid'
    natural = 'natural'


class CreateImageRequest(BaseModel):
    prompt: str = Field(..., examples=['A cute baby sea otter'])
    """
    A text description of the desired image(s). The maximum length is 1000 characters for `dall-e-2` and 4000 characters for `dall-e-3`.
    """
    model: Optional[Union[Optional[str], Model6]] = Field(
        'dall-e-2', examples=['dall-e-3']
    )
    """
    The model to use for image generation.
    """
    n: Optional[int] = Field(1, examples=[1], ge=1, le=10)
    """
    The number of images to generate. Must be between 1 and 10. For `dall-e-3`, only `n=1` is supported.
    """
    quality: Quality = Field('standard', examples=['standard'])
    """
    The quality of the image that will be generated. `hd` creates images with finer details and greater consistency across the image. This param is only supported for `dall-e-3`.
    """
    response_format: Optional[ResponseFormat] = Field('url', examples=['url'])
    """
    The format in which the generated images are returned. Must be one of `url` or `b64_json`. URLs are only valid for 60 minutes after the image has been generated.
    """
    size: Optional[Size1] = Field('1024x1024', examples=['1024x1024'])
    """
    The size of the generated images. Must be one of `256x256`, `512x512`, or `1024x1024` for `dall-e-2`. Must be one of `1024x1024`, `1792x1024`, or `1024x1792` for `dall-e-3` models.
    """
    style: Optional[Style] = Field('vivid', examples=['vivid'])
    """
    The style of the generated images. Must be one of `vivid` or `natural`. Vivid causes the model to lean towards generating hyper-real and dramatic images. Natural causes the model to produce more natural, less hyper-real looking images. This param is only supported for `dall-e-3`.
    """
    user: Optional[str] = Field(None, examples=['user-1234'])
    """
    A unique identifier representing your end-user, which can help OpenAI to monitor and detect abuse. [Learn more](/docs/guides/safety-best-practices/end-user-ids).

    """


class CreateImageVariationRequest(BaseModel):
    image: bytes
    """
    The image to use as the basis for the variation(s). Must be a valid PNG file, less than 4MB, and square.
    """
    model: Optional[Union[Optional[str], Model5]] = Field(
        'dall-e-2', examples=['dall-e-2']
    )
    """
    The model to use for image generation. Only `dall-e-2` is supported at this time.
    """
    n: Optional[int] = Field(1, examples=[1], ge=1, le=10)
    """
    The number of images to generate. Must be between 1 and 10. For `dall-e-3`, only `n=1` is supported.
    """
    response_format: Optional[ResponseFormat] = Field('url', examples=['url'])
    """
    The format in which the generated images are returned. Must be one of `url` or `b64_json`. URLs are only valid for 60 minutes after the image has been generated.
    """
    size: Optional[Size] = Field('1024x1024', examples=['1024x1024'])
    """
    The size of the generated images. Must be one of `256x256`, `512x512`, or `1024x1024`.
    """
    user: Optional[str] = Field(None, examples=['user-1234'])
    """
    A unique identifier representing your end-user, which can help OpenAI to monitor and detect abuse. [Learn more](/docs/guides/safety-best-practices/end-user-ids).

    """


class Role7(str, Enum):
    """
    The role of the entity that is creating the message. Allowed values include:
    - `user`: Indicates the message is sent by an actual user and should be used in most cases to represent user-generated messages.
    - `assistant`: Indicates the message is generated by the assistant. Use this value to insert messages from the assistant into the conversation.

    """

    user = 'user'
    assistant = 'assistant'


class Attachment(BaseModel):
    file_id: Optional[str] = None
    """
    The ID of the file to attach to the message.
    """
    tools: Optional[
        List[Union[AssistantToolsCode, AssistantToolsFileSearchTypeOnly]]
    ] = None
    """
    The tools to add this file to.
    """


class Type21(str, Enum):
    """
    Always `image_url`.
    """

    image_url = 'image_url'


class ImageUrl1(BaseModel):
    """
    Contains either an image URL or a data URL for a base64 encoded image.
    """

    url: AnyUrl = Field(..., examples=['https://example.com/image.jpg'])
    """
    Either a URL of the image or the base64 encoded image data.
    """


class Input3(BaseModel):
    """
    An object describing an image to classify.
    """

    type: Type21
    """
    Always `image_url`.
    """
    image_url: ImageUrl1
    """
    Contains either an image URL or a data URL for a base64 encoded image.
    """


class Type22(str, Enum):
    """
    Always `text`.
    """

    text = 'text'


class Input4(BaseModel):
    """
    An object describing text to classify.
    """

    type: Type22
    """
    Always `text`.
    """
    text: str = Field(..., examples=['I want to kill them'])
    """
    A string of text to classify.
    """


class Model8(str, Enum):
    """
    The content moderation model you would like to use. Learn more in
    [the moderation guide](/docs/guides/moderation), and learn about
    available models [here](/docs/models/moderation).

    """

    omni_moderation_latest = 'omni-moderation-latest'
    omni_moderation_2024_09_26 = 'omni-moderation-2024-09-26'
    text_moderation_latest = 'text-moderation-latest'
    text_moderation_stable = 'text-moderation-stable'


class CreateModerationRequest(BaseModel):
    input: Union[str, List[str], List[Union[Input3, Input4]]]
    """
    Input (or inputs) to classify. Can be a single string, an array of strings, or
    an array of multi-modal input objects similar to other models.

    """
    model: Union[str, Model8] = Field(
        'omni-moderation-latest', examples=['omni-moderation-2024-09-26']
    )
    """
    The content moderation model you would like to use. Learn more in
    [the moderation guide](/docs/guides/moderation), and learn about
    available models [here](/docs/models/moderation).

    """


class Categories(BaseModel):
    """
    A list of the categories, and whether they are flagged or not.
    """

    hate: bool
    """
    Content that expresses, incites, or promotes hate based on race, gender, ethnicity, religion, nationality, sexual orientation, disability status, or caste. Hateful content aimed at non-protected groups (e.g., chess players) is harassment.
    """
    hate_threatening: bool = Field(..., alias='hate/threatening')
    """
    Hateful content that also includes violence or serious harm towards the targeted group based on race, gender, ethnicity, religion, nationality, sexual orientation, disability status, or caste.
    """
    harassment: bool
    """
    Content that expresses, incites, or promotes harassing language towards any target.
    """
    harassment_threatening: bool = Field(..., alias='harassment/threatening')
    """
    Harassment content that also includes violence or serious harm towards any target.
    """
    illicit: bool
    """
    Content that includes instructions or advice that facilitate the planning or execution of wrongdoing, or that gives advice or instruction on how to commit illicit acts. For example, "how to shoplift" would fit this category.
    """
    illicit_violent: bool = Field(..., alias='illicit/violent')
    """
    Content that includes instructions or advice that facilitate the planning or execution of wrongdoing that also includes violence, or that gives advice or instruction on the procurement of any weapon.
    """
    self_harm: bool = Field(..., alias='self-harm')
    """
    Content that promotes, encourages, or depicts acts of self-harm, such as suicide, cutting, and eating disorders.
    """
    self_harm_intent: bool = Field(..., alias='self-harm/intent')
    """
    Content where the speaker expresses that they are engaging or intend to engage in acts of self-harm, such as suicide, cutting, and eating disorders.
    """
    self_harm_instructions: bool = Field(..., alias='self-harm/instructions')
    """
    Content that encourages performing acts of self-harm, such as suicide, cutting, and eating disorders, or that gives instructions or advice on how to commit such acts.
    """
    sexual: bool
    """
    Content meant to arouse sexual excitement, such as the description of sexual activity, or that promotes sexual services (excluding sex education and wellness).
    """
    sexual_minors: bool = Field(..., alias='sexual/minors')
    """
    Sexual content that includes an individual who is under 18 years old.
    """
    violence: bool
    """
    Content that depicts death, violence, or physical injury.
    """
    violence_graphic: bool = Field(..., alias='violence/graphic')
    """
    Content that depicts death, violence, or physical injury in graphic detail.
    """


class CategoryScores(BaseModel):
    """
    A list of the categories along with their scores as predicted by model.
    """

    hate: float
    """
    The score for the category 'hate'.
    """
    hate_threatening: float = Field(..., alias='hate/threatening')
    """
    The score for the category 'hate/threatening'.
    """
    harassment: float
    """
    The score for the category 'harassment'.
    """
    harassment_threatening: float = Field(..., alias='harassment/threatening')
    """
    The score for the category 'harassment/threatening'.
    """
    illicit: float
    """
    The score for the category 'illicit'.
    """
    illicit_violent: float = Field(..., alias='illicit/violent')
    """
    The score for the category 'illicit/violent'.
    """
    self_harm: float = Field(..., alias='self-harm')
    """
    The score for the category 'self-harm'.
    """
    self_harm_intent: float = Field(..., alias='self-harm/intent')
    """
    The score for the category 'self-harm/intent'.
    """
    self_harm_instructions: float = Field(..., alias='self-harm/instructions')
    """
    The score for the category 'self-harm/instructions'.
    """
    sexual: float
    """
    The score for the category 'sexual'.
    """
    sexual_minors: float = Field(..., alias='sexual/minors')
    """
    The score for the category 'sexual/minors'.
    """
    violence: float
    """
    The score for the category 'violence'.
    """
    violence_graphic: float = Field(..., alias='violence/graphic')
    """
    The score for the category 'violence/graphic'.
    """


class HateEnum(str, Enum):
    text = 'text'


class SelfHarmEnum(str, Enum):
    text = 'text'
    image = 'image'


class CategoryAppliedInputTypes(BaseModel):
    """
    A list of the categories along with the input type(s) that the score applies to.
    """

    hate: List[HateEnum]
    """
    The applied input type(s) for the category 'hate'.
    """
    hate_threatening: List[HateEnum] = Field(..., alias='hate/threatening')
    """
    The applied input type(s) for the category 'hate/threatening'.
    """
    harassment: List[HateEnum]
    """
    The applied input type(s) for the category 'harassment'.
    """
    harassment_threatening: List[HateEnum] = Field(..., alias='harassment/threatening')
    """
    The applied input type(s) for the category 'harassment/threatening'.
    """
    illicit: List[HateEnum]
    """
    The applied input type(s) for the category 'illicit'.
    """
    illicit_violent: List[HateEnum] = Field(..., alias='illicit/violent')
    """
    The applied input type(s) for the category 'illicit/violent'.
    """
    self_harm: List[SelfHarmEnum] = Field(..., alias='self-harm')
    """
    The applied input type(s) for the category 'self-harm'.
    """
    self_harm_intent: List[SelfHarmEnum] = Field(..., alias='self-harm/intent')
    """
    The applied input type(s) for the category 'self-harm/intent'.
    """
    self_harm_instructions: List[SelfHarmEnum] = Field(
        ..., alias='self-harm/instructions'
    )
    """
    The applied input type(s) for the category 'self-harm/instructions'.
    """
    sexual: List[SelfHarmEnum]
    """
    The applied input type(s) for the category 'sexual'.
    """
    sexual_minors: List[HateEnum] = Field(..., alias='sexual/minors')
    """
    The applied input type(s) for the category 'sexual/minors'.
    """
    violence: List[SelfHarmEnum]
    """
    The applied input type(s) for the category 'violence'.
    """
    violence_graphic: List[SelfHarmEnum] = Field(..., alias='violence/graphic')
    """
    The applied input type(s) for the category 'violence/graphic'.
    """


class Result(BaseModel):
    flagged: bool
    """
    Whether any of the below categories are flagged.
    """
    categories: Categories
    """
    A list of the categories, and whether they are flagged or not.
    """
    category_scores: CategoryScores
    """
    A list of the categories along with their scores as predicted by model.
    """
    category_applied_input_types: CategoryAppliedInputTypes
    """
    A list of the categories along with the input type(s) that the score applies to.
    """


class CreateModerationResponse(BaseModel):
    """
    Represents if a given text input is potentially harmful.
    """

    id: str
    """
    The unique identifier for the moderation request.
    """
    model: str
    """
    The model used to generate the moderation results.
    """
    results: List[Result]
    """
    A list of moderation objects.
    """


class Model9(str, Enum):
    """
    The ID of the [Model](/docs/api-reference/models) to be used to execute this run. If a value is provided here, it will override the model associated with the assistant. If not, the model associated with the assistant will be used.
    """

    gpt_4o = 'gpt-4o'
    gpt_4o_2024_08_06 = 'gpt-4o-2024-08-06'
    gpt_4o_2024_05_13 = 'gpt-4o-2024-05-13'
    gpt_4o_2024_08_06_1 = 'gpt-4o-2024-08-06'
    gpt_4o_mini = 'gpt-4o-mini'
    gpt_4o_mini_2024_07_18 = 'gpt-4o-mini-2024-07-18'
    gpt_4_turbo = 'gpt-4-turbo'
    gpt_4_turbo_2024_04_09 = 'gpt-4-turbo-2024-04-09'
    gpt_4_0125_preview = 'gpt-4-0125-preview'
    gpt_4_turbo_preview = 'gpt-4-turbo-preview'
    gpt_4_1106_preview = 'gpt-4-1106-preview'
    gpt_4_vision_preview = 'gpt-4-vision-preview'
    gpt_4 = 'gpt-4'
    gpt_4_0314 = 'gpt-4-0314'
    gpt_4_0613 = 'gpt-4-0613'
    gpt_4_32k = 'gpt-4-32k'
    gpt_4_32k_0314 = 'gpt-4-32k-0314'
    gpt_4_32k_0613 = 'gpt-4-32k-0613'
    gpt_3_5_turbo = 'gpt-3.5-turbo'
    gpt_3_5_turbo_16k = 'gpt-3.5-turbo-16k'
    gpt_3_5_turbo_0613 = 'gpt-3.5-turbo-0613'
    gpt_3_5_turbo_1106 = 'gpt-3.5-turbo-1106'
    gpt_3_5_turbo_0125 = 'gpt-3.5-turbo-0125'
    gpt_3_5_turbo_16k_0613 = 'gpt-3.5-turbo-16k-0613'


class Model10(str, Enum):
    """
    One of the available [TTS models](/docs/models/tts): `tts-1` or `tts-1-hd`

    """

    tts_1 = 'tts-1'
    tts_1_hd = 'tts-1-hd'


class Voice1(str, Enum):
    """
    The voice to use when generating the audio. Supported voices are `alloy`, `echo`, `fable`, `onyx`, `nova`, and `shimmer`. Previews of the voices are available in the [Text to speech guide](/docs/guides/text-to-speech/voice-options).
    """

    alloy = 'alloy'
    echo = 'echo'
    fable = 'fable'
    onyx = 'onyx'
    nova = 'nova'
    shimmer = 'shimmer'


class ResponseFormat3(str, Enum):
    """
    The format to audio in. Supported formats are `mp3`, `opus`, `aac`, `flac`, `wav`, and `pcm`.
    """

    mp3 = 'mp3'
    opus = 'opus'
    aac = 'aac'
    flac = 'flac'
    wav = 'wav'
    pcm = 'pcm'


class CreateSpeechRequest(BaseModel):
    model_config = ConfigDict(
        extra='forbid',
    )
    model: Union[str, Model10]
    """
    One of the available [TTS models](/docs/models/tts): `tts-1` or `tts-1-hd`

    """
    input: str = Field(..., max_length=4096)
    """
    The text to generate audio for. The maximum length is 4096 characters.
    """
    voice: Voice1
    """
    The voice to use when generating the audio. Supported voices are `alloy`, `echo`, `fable`, `onyx`, `nova`, and `shimmer`. Previews of the voices are available in the [Text to speech guide](/docs/guides/text-to-speech/voice-options).
    """
    response_format: ResponseFormat3 = 'mp3'
    """
    The format to audio in. Supported formats are `mp3`, `opus`, `aac`, `flac`, `wav`, and `pcm`.
    """
    speed: float = Field(1, ge=0.25, le=4.0)
    """
    The speed of the generated audio. Select a value from `0.25` to `4.0`. `1.0` is the default.
    """


class FileSearch4(FileSearch):
    pass


class ToolResources2(BaseModel):
    """
    A set of resources that are used by the assistant's tools. The resources are specific to the type of tool. For example, the `code_interpreter` tool requires a list of file IDs, while the `file_search` tool requires a list of vector store IDs.

    """

    code_interpreter: Optional[CodeInterpreter1] = None
    file_search: Optional[FileSearch4] = None


class ChunkingStrategy4(AutoChunkingStrategyRequestParam):
    """
    The default strategy. This strategy currently uses a `max_chunk_size_tokens` of `800` and `chunk_overlap_tokens` of `400`.
    """


class ChunkingStrategy5(ChunkingStrategy1):
    """
    The chunking strategy used to chunk the file(s). If not set, will use the `auto` strategy.
    """


class VectorStore2(BaseModel):
    file_ids: Optional[List[str]] = Field(None, max_length=10000)
    """
    A list of [file](/docs/api-reference/files) IDs to add to the vector store. There can be a maximum of 10000 files in a vector store.

    """
    chunking_strategy: Optional[Union[ChunkingStrategy4, ChunkingStrategy5]] = None
    """
    The chunking strategy used to chunk the file(s). If not set, will use the `auto` strategy.
    """
    metadata: Optional[Dict[str, Any]] = None
    """
    Set of 16 key-value pairs that can be attached to a vector store. This can be useful for storing additional information about the vector store in a structured format. Keys can be a maximum of 64 characters long and values can be a maximum of 512 characters long.

    """


class FileSearch5(BaseModel):
    vector_store_ids: List[str] = Field(..., max_length=1)
    """
    The [vector store](/docs/api-reference/vector-stores/object) attached to this thread. There can be a maximum of 1 vector store attached to the thread.

    """
    vector_stores: Optional[List[VectorStore2]] = Field(None, max_length=1)
    """
    A helper to create a [vector store](/docs/api-reference/vector-stores/object) with file_ids and attach it to this thread. There can be a maximum of 1 vector store attached to the thread.

    """


class ChunkingStrategy6(AutoChunkingStrategyRequestParam):
    """
    The default strategy. This strategy currently uses a `max_chunk_size_tokens` of `800` and `chunk_overlap_tokens` of `400`.
    """


class ChunkingStrategy7(ChunkingStrategy1):
    """
    The chunking strategy used to chunk the file(s). If not set, will use the `auto` strategy.
    """


class VectorStore3(BaseModel):
    file_ids: Optional[List[str]] = Field(None, max_length=10000)
    """
    A list of [file](/docs/api-reference/files) IDs to add to the vector store. There can be a maximum of 10000 files in a vector store.

    """
    chunking_strategy: Optional[Union[ChunkingStrategy6, ChunkingStrategy7]] = None
    """
    The chunking strategy used to chunk the file(s). If not set, will use the `auto` strategy.
    """
    metadata: Optional[Dict[str, Any]] = None
    """
    Set of 16 key-value pairs that can be attached to a vector store. This can be useful for storing additional information about the vector store in a structured format. Keys can be a maximum of 64 characters long and values can be a maximum of 512 characters long.

    """


class FileSearch6(BaseModel):
    vector_store_ids: Optional[List[str]] = Field(None, max_length=1)
    """
    The [vector store](/docs/api-reference/vector-stores/object) attached to this thread. There can be a maximum of 1 vector store attached to the thread.

    """
    vector_stores: List[VectorStore3] = Field(..., max_length=1)
    """
    A helper to create a [vector store](/docs/api-reference/vector-stores/object) with file_ids and attach it to this thread. There can be a maximum of 1 vector store attached to the thread.

    """


class ToolResources3(BaseModel):
    """
    A set of resources that are made available to the assistant's tools in this thread. The resources are specific to the type of tool. For example, the `code_interpreter` tool requires a list of file IDs, while the `file_search` tool requires a list of vector store IDs.

    """

    code_interpreter: Optional[CodeInterpreter1] = None
    file_search: Optional[Union[FileSearch5, FileSearch6]] = None


class Model12(str, Enum):
    """
    ID of the model to use. Only `whisper-1` (which is powered by our open source Whisper V2 model) is currently available.

    """

    whisper_1 = 'whisper-1'


class TimestampGranularity(str, Enum):
    word = 'word'
    segment = 'segment'


class CreateTranscriptionRequest(BaseModel):
    model_config = ConfigDict(
        extra='forbid',
    )
    file: bytes
    """
    The audio file object (not file name) to transcribe, in one of these formats: flac, mp3, mp4, mpeg, mpga, m4a, ogg, wav, or webm.

    """
    model: Union[str, Model12] = Field(..., examples=['whisper-1'])
    """
    ID of the model to use. Only `whisper-1` (which is powered by our open source Whisper V2 model) is currently available.

    """
    language: Optional[str] = None
    """
    The language of the input audio. Supplying the input language in [ISO-639-1](https://en.wikipedia.org/wiki/List_of_ISO_639-1_codes) format will improve accuracy and latency.

    """
    prompt: Optional[str] = None
    """
    An optional text to guide the model's style or continue a previous audio segment. The [prompt](/docs/guides/speech-to-text/prompting) should match the audio language.

    """
    response_format: Optional[AudioResponseFormat] = 'json'
    temperature: float = 0
    """
    The sampling temperature, between 0 and 1. Higher values like 0.8 will make the output more random, while lower values like 0.2 will make it more focused and deterministic. If set to 0, the model will use [log probability](https://en.wikipedia.org/wiki/Log_probability) to automatically increase the temperature until certain thresholds are hit.

    """
    timestamp_granularities__: List[TimestampGranularity] = Field(
        ['segment'], alias='timestamp_granularities[]'
    )
    """
    The timestamp granularities to populate for this transcription. `response_format` must be set `verbose_json` to use timestamp granularities. Either or both of these options are supported: `word`, or `segment`. Note: There is no additional latency for segment timestamps, but generating word timestamps incurs additional latency.

    """


class CreateTranscriptionResponseJson(BaseModel):
    """
    Represents a transcription response returned by model, based on the provided input.
    """

    text: str
    """
    The transcribed text.
    """


class CreateTranslationRequest(BaseModel):
    model_config = ConfigDict(
        extra='forbid',
    )
    file: bytes
    """
    The audio file object (not file name) translate, in one of these formats: flac, mp3, mp4, mpeg, mpga, m4a, ogg, wav, or webm.

    """
    model: Union[str, Model12] = Field(..., examples=['whisper-1'])
    """
    ID of the model to use. Only `whisper-1` (which is powered by our open source Whisper V2 model) is currently available.

    """
    prompt: Optional[str] = None
    """
    An optional text to guide the model's style or continue a previous audio segment. The [prompt](/docs/guides/speech-to-text/prompting) should be in English.

    """
    response_format: Optional[AudioResponseFormat] = 'json'
    temperature: float = 0
    """
    The sampling temperature, between 0 and 1. Higher values like 0.8 will make the output more random, while lower values like 0.2 will make it more focused and deterministic. If set to 0, the model will use [log probability](https://en.wikipedia.org/wiki/Log_probability) to automatically increase the temperature until certain thresholds are hit.

    """


class CreateTranslationResponseJson(BaseModel):
    text: str


class Purpose1(str, Enum):
    """
    The intended purpose of the uploaded file.

    See the [documentation on File purposes](/docs/api-reference/files/create#files-create-purpose).

    """

    assistants = 'assistants'
    batch = 'batch'
    fine_tune = 'fine-tune'
    vision = 'vision'


class CreateUploadRequest(BaseModel):
    model_config = ConfigDict(
        extra='forbid',
    )
    filename: str
    """
    The name of the file to upload.

    """
    purpose: Purpose1
    """
    The intended purpose of the uploaded file.

    See the [documentation on File purposes](/docs/api-reference/files/create#files-create-purpose).

    """
    bytes: int
    """
    The number of bytes in the file you are uploading.

    """
    mime_type: str
    """
    The MIME type of the file.

    This must fall within the supported MIME types for your file purpose. See the supported MIME types for assistants and vision.

    """


class DefaultProjectErrorResponse(BaseModel):
    code: int
    message: str


class Object7(str, Enum):
    assistant_deleted = 'assistant.deleted'


class DeleteAssistantResponse(BaseModel):
    id: str
    deleted: bool
    object: Object7


class Object8(str, Enum):
    file = 'file'


class DeleteFileResponse(BaseModel):
    id: str
    object: Object8
    deleted: bool


class Object9(str, Enum):
    thread_message_deleted = 'thread.message.deleted'


class DeleteMessageResponse(BaseModel):
    id: str
    deleted: bool
    object: Object9


class DeleteModelResponse(BaseModel):
    id: str
    deleted: bool
    object: str


class Object10(str, Enum):
    thread_deleted = 'thread.deleted'


class DeleteThreadResponse(BaseModel):
    id: str
    deleted: bool
    object: Object10


class Object11(str, Enum):
    vector_store_file_deleted = 'vector_store.file.deleted'


class DeleteVectorStoreFileResponse(BaseModel):
    id: str
    deleted: bool
    object: Object11


class Object12(str, Enum):
    vector_store_deleted = 'vector_store.deleted'


class DeleteVectorStoreResponse(BaseModel):
    id: str
    deleted: bool
    object: Object12


class Event(str, Enum):
    done = 'done'


class Data5(str, Enum):
    field_DONE_ = '[DONE]'


class DoneEvent(BaseModel):
    """
    Occurs when a stream ends.
    """

    event: Event
    data: Data5


class Object13(str, Enum):
    """
    The object type, which is always "embedding".
    """

    embedding = 'embedding'


class Embedding(BaseModel):
    """
    Represents an embedding vector returned by embedding endpoint.

    """

    index: int
    """
    The index of the embedding in the list of embeddings.
    """
    embedding: List[float]
    """
    The embedding vector, which is a list of floats. The length of vector depends on the model as listed in the [embedding guide](/docs/guides/embeddings).

    """
    object: Object13
    """
    The object type, which is always "embedding".
    """


class Error1(BaseModel):
    code: Optional[str] = Field(None)
    message: str
    param: Optional[str] = Field(None)
    type: str


class Event1(str, Enum):
    error = 'error'


class ErrorEvent(BaseModel):
    """
    Occurs when an [error](/docs/guides/error-codes/api-errors) occurs. This can happen due to an internal server error or a timeout.
    """

    event: Event1
    data: Error1


class ErrorResponse(BaseModel):
    error: Error1


class Ranker(str, Enum):
    """
    The ranker to use for the file search. If not specified will use the `auto` ranker.
    """

    auto = 'auto'
    default_2024_08_21 = 'default_2024_08_21'


class FileSearchRankingOptions(BaseModel):
    """
    The ranking options for the file search. If not specified, the file search tool will use the `auto` ranker and a score_threshold of 0.

    See the [file search tool documentation](/docs/assistants/tools/file-search/customizing-file-search-settings) for more information.

    """

    ranker: Optional[Ranker] = None
    """
    The ranker to use for the file search. If not specified will use the `auto` ranker.
    """
    score_threshold: float = Field(..., ge=0.0, le=1.0)
    """
    The score threshold for the file search. All values must be a floating point number between 0 and 1.
    """


class Weight(int, Enum):
    """
    Controls whether the assistant message is trained against (0 or 1)
    """

    integer_0 = 0
    integer_1 = 1


class Type27(str, Enum):
    """
    The type of the integration being enabled for the fine-tuning job
    """

    wandb = 'wandb'


class FineTuningIntegration(BaseModel):
    type: Type27
    """
    The type of the integration being enabled for the fine-tuning job
    """
    wandb: Wandb
    """
    The settings for your integration with Weights and Biases. This payload specifies the project that
    metrics will be sent to. Optionally, you can set an explicit display name for your run, add tags
    to your run, and set a default entity (team, username, etc) to be associated with your run.

    """


class Error2(BaseModel):
    """
    For fine-tuning jobs that have `failed`, this will contain more information on the cause of the failure.
    """

    code: str
    """
    A machine-readable error code.
    """
    message: str
    """
    A human-readable error message.
    """
    param: Optional[str] = Field(None)
    """
    The parameter that was invalid, usually `training_file` or `validation_file`. This field will be null if the failure was not parameter-specific.
    """


class NEpochs2(str, Enum):
    """
    The number of epochs to train the model for. An epoch refers to one full cycle through the training dataset.
    "auto" decides the optimal number of epochs based on the size of the dataset. If setting the number manually, we support any number between 1 and 50 epochs.
    """

    auto = 'auto'


class NEpochs3(RootModel[int]):
    root: int = Field(..., ge=1, le=50)
    """
    The number of epochs to train the model for. An epoch refers to one full cycle through the training dataset.
    "auto" decides the optimal number of epochs based on the size of the dataset. If setting the number manually, we support any number between 1 and 50 epochs.
    """


class Hyperparameters1(BaseModel):
    """
    The hyperparameters used for the fine-tuning job. See the [fine-tuning guide](/docs/guides/fine-tuning) for more details.
    """

    n_epochs: Union[NEpochs2, NEpochs3]
    """
    The number of epochs to train the model for. An epoch refers to one full cycle through the training dataset.
    "auto" decides the optimal number of epochs based on the size of the dataset. If setting the number manually, we support any number between 1 and 50 epochs.
    """


class Object14(str, Enum):
    """
    The object type, which is always "fine_tuning.job".
    """

    fine_tuning_job = 'fine_tuning.job'


class Status1(str, Enum):
    """
    The current status of the fine-tuning job, which can be either `validating_files`, `queued`, `running`, `succeeded`, `failed`, or `cancelled`.
    """

    validating_files = 'validating_files'
    queued = 'queued'
    running = 'running'
    succeeded = 'succeeded'
    failed = 'failed'
    cancelled = 'cancelled'


class FineTuningJob(BaseModel):
    """
    The `fine_tuning.job` object represents a fine-tuning job that has been created through the API.

    """

    id: str
    """
    The object identifier, which can be referenced in the API endpoints.
    """
    created_at: int
    """
    The Unix timestamp (in seconds) for when the fine-tuning job was created.
    """
    error: Optional[Error2] = Field(None)
    """
    For fine-tuning jobs that have `failed`, this will contain more information on the cause of the failure.
    """
    fine_tuned_model: Optional[str] = Field(None)
    """
    The name of the fine-tuned model that is being created. The value will be null if the fine-tuning job is still running.
    """
    finished_at: Optional[int] = Field(None)
    """
    The Unix timestamp (in seconds) for when the fine-tuning job was finished. The value will be null if the fine-tuning job is still running.
    """
    hyperparameters: Hyperparameters1
    """
    The hyperparameters used for the fine-tuning job. See the [fine-tuning guide](/docs/guides/fine-tuning) for more details.
    """
    model: str
    """
    The base model that is being fine-tuned.
    """
    object: Object14
    """
    The object type, which is always "fine_tuning.job".
    """
    organization_id: str
    """
    The organization that owns the fine-tuning job.
    """
    result_files: List[str]
    """
    The compiled results file ID(s) for the fine-tuning job. You can retrieve the results with the [Files API](/docs/api-reference/files/retrieve-contents).
    """
    status: Status1
    """
    The current status of the fine-tuning job, which can be either `validating_files`, `queued`, `running`, `succeeded`, `failed`, or `cancelled`.
    """
    trained_tokens: Optional[int] = Field(None)
    """
    The total number of billable tokens processed by this fine-tuning job. The value will be null if the fine-tuning job is still running.
    """
    training_file: str
    """
    The file ID used for training. You can retrieve the training data with the [Files API](/docs/api-reference/files/retrieve-contents).
    """
    validation_file: Optional[str] = Field(None)
    """
    The file ID used for validation. You can retrieve the validation results with the [Files API](/docs/api-reference/files/retrieve-contents).
    """
    integrations: Optional[List[FineTuningIntegration]] = Field(None, max_length=5)
    """
    A list of integrations to enable for this fine-tuning job.
    """
    seed: int
    """
    The seed used for the fine-tuning job.
    """
    estimated_finish: Optional[int] = None
    """
    The Unix timestamp (in seconds) for when the fine-tuning job is estimated to finish. The value will be null if the fine-tuning job is not running.
    """


class Metrics(BaseModel):
    """
    Metrics at the step number during the fine-tuning job.
    """

    step: Optional[float] = None
    train_loss: Optional[float] = None
    train_mean_token_accuracy: Optional[float] = None
    valid_loss: Optional[float] = None
    valid_mean_token_accuracy: Optional[float] = None
    full_valid_loss: Optional[float] = None
    full_valid_mean_token_accuracy: Optional[float] = None


class Object15(str, Enum):
    """
    The object type, which is always "fine_tuning.job.checkpoint".
    """

    fine_tuning_job_checkpoint = 'fine_tuning.job.checkpoint'


class FineTuningJobCheckpoint(BaseModel):
    """
    The `fine_tuning.job.checkpoint` object represents a model checkpoint for a fine-tuning job that is ready to use.

    """

    id: str
    """
    The checkpoint identifier, which can be referenced in the API endpoints.
    """
    created_at: int
    """
    The Unix timestamp (in seconds) for when the checkpoint was created.
    """
    fine_tuned_model_checkpoint: str
    """
    The name of the fine-tuned checkpoint model that is created.
    """
    step_number: int
    """
    The step number that the checkpoint was created at.
    """
    metrics: Metrics
    """
    Metrics at the step number during the fine-tuning job.
    """
    fine_tuning_job_id: str
    """
    The name of the fine-tuning job that this checkpoint was created from.
    """
    object: Object15
    """
    The object type, which is always "fine_tuning.job.checkpoint".
    """


class Level(str, Enum):
    info = 'info'
    warn = 'warn'
    error = 'error'


class Object16(str, Enum):
    fine_tuning_job_event = 'fine_tuning.job.event'


class FineTuningJobEvent(BaseModel):
    """
    Fine-tuning job event object
    """

    id: str
    created_at: int
    level: Level
    message: str
    object: Object16


class FinetuneCompletionRequestInput(BaseModel):
    """
    The per-line training example of a fine-tuning input file for completions models
    """

    prompt: Optional[str] = None
    """
    The input prompt for this training example.
    """
    completion: Optional[str] = None
    """
    The desired completion for this training example.
    """


class FunctionParameters(BaseModel):
    """
    The parameters the functions accepts, described as a JSON Schema object. See the [guide](/docs/guides/function-calling) for examples, and the [JSON Schema reference](https://json-schema.org/understanding-json-schema/) for documentation about the format.

    Omitting `parameters` defines a function with an empty parameter list.
    """

    model_config = ConfigDict(
        extra='allow',
    )


class Image(BaseModel):
    """
    Represents the url or the content of an image generated by the OpenAI API.
    """

    b64_json: Optional[str] = None
    """
    The base64-encoded JSON of the generated image, if `response_format` is `b64_json`.
    """
    url: Optional[str] = None
    """
    The URL of the generated image, if `response_format` is `url` (default).
    """
    revised_prompt: Optional[str] = None
    """
    The prompt that was used to generate the image, if there was any revision to the prompt.
    """


class ImagesResponse(BaseModel):
    created: int
    data: List[Image]


class Object17(str, Enum):
    """
    The object type, which is always `organization.invite`
    """

    organization_invite = 'organization.invite'


class Role8(str, Enum):
    """
    `owner` or `reader`
    """

    owner = 'owner'
    reader = 'reader'


class Status2(str, Enum):
    """
    `accepted`,`expired`, or `pending`
    """

    accepted = 'accepted'
    expired = 'expired'
    pending = 'pending'


class Invite(BaseModel):
    """
    Represents an individual `invite` to the organization.
    """

    object: Object17
    """
    The object type, which is always `organization.invite`
    """
    id: str
    """
    The identifier, which can be referenced in API endpoints
    """
    email: str
    """
    The email address of the individual to whom the invite was sent
    """
    role: Role8
    """
    `owner` or `reader`
    """
    status: Status2
    """
    `accepted`,`expired`, or `pending`
    """
    invited_at: int
    """
    The Unix timestamp (in seconds) of when the invite was sent.
    """
    expires_at: int
    """
    The Unix timestamp (in seconds) of when the invite expires.
    """
    accepted_at: Optional[int] = None
    """
    The Unix timestamp (in seconds) of when the invite was accepted.
    """


class Object18(str, Enum):
    """
    The object type, which is always `organization.invite.deleted`
    """

    organization_invite_deleted = 'organization.invite.deleted'


class InviteDeleteResponse(BaseModel):
    object: Object18
    """
    The object type, which is always `organization.invite.deleted`
    """
    id: str
    deleted: bool


class Object19(str, Enum):
    """
    The object type, which is always `list`
    """

    list = 'list'


class InviteListResponse(BaseModel):
    object: Object19
    """
    The object type, which is always `list`
    """
    data: List[Invite]
    first_id: Optional[str] = None
    """
    The first `invite_id` in the retrieved `list`
    """
    last_id: Optional[str] = None
    """
    The last `invite_id` in the retrieved `list`
    """
    has_more: Optional[bool] = None
    """
    The `has_more` property is used for pagination to indicate there are additional results.
    """


class Role9(str, Enum):
    """
    `owner` or `reader`
    """

    reader = 'reader'
    owner = 'owner'


class InviteRequest(BaseModel):
    email: str
    """
    Send an email to this address
    """
    role: Role9
    """
    `owner` or `reader`
    """


class Object20(str, Enum):
    list = 'list'


class ListBatchesResponse(BaseModel):
    data: List[Batch]
    first_id: Optional[str] = Field(None, examples=['batch_abc123'])
    last_id: Optional[str] = Field(None, examples=['batch_abc456'])
    has_more: bool
    object: Object20


class ListFineTuningJobCheckpointsResponse(BaseModel):
    data: List[FineTuningJobCheckpoint]
    object: Object20
    first_id: Optional[str] = None
    last_id: Optional[str] = None
    has_more: bool


class ListFineTuningJobEventsResponse(BaseModel):
    data: List[FineTuningJobEvent]
    object: Object20


class ListPaginatedFineTuningJobsResponse(BaseModel):
    data: List[FineTuningJob]
    has_more: bool
    object: Object20


class Type28(str, Enum):
    """
    Always `image_file`.
    """

    image_file = 'image_file'


class Detail1(str, Enum):
    """
    Specifies the detail level of the image if specified by the user. `low` uses fewer tokens, you can opt in to high resolution using `high`.
    """

    auto = 'auto'
    low = 'low'
    high = 'high'


class ImageFile(BaseModel):
    file_id: str
    """
    The [File](/docs/api-reference/files) ID of the image in the message content. Set `purpose="vision"` when uploading the File if you need to later display the file content.
    """
    detail: Detail1 = 'auto'
    """
    Specifies the detail level of the image if specified by the user. `low` uses fewer tokens, you can opt in to high resolution using `high`.
    """


class MessageContentImageFileObject(BaseModel):
    """
    References an image [File](/docs/api-reference/files) in the content of a message.
    """

    type: Type28
    """
    Always `image_file`.
    """
    image_file: ImageFile


class Detail2(str, Enum):
    """
    Specifies the detail level of the image. `low` uses fewer tokens, you can opt in to high resolution using `high`. Default value is `auto`
    """

    auto = 'auto'
    low = 'low'
    high = 'high'


class ImageUrl2(BaseModel):
    url: AnyUrl
    """
    The external URL of the image, must be a supported image types: jpeg, jpg, png, gif, webp.
    """
    detail: Detail2 = 'auto'
    """
    Specifies the detail level of the image. `low` uses fewer tokens, you can opt in to high resolution using `high`. Default value is `auto`
    """


class MessageContentImageUrlObject(BaseModel):
    """
    References an image URL in the content of a message.
    """

    type: Type12
    """
    The type of the content part.
    """
    image_url: ImageUrl2


class Type30(str, Enum):
    """
    Always `refusal`.
    """

    refusal = 'refusal'


class MessageContentRefusalObject(BaseModel):
    """
    The refusal content generated by the assistant.
    """

    type: Type30
    """
    Always `refusal`.
    """
    refusal: str


class Type31(str, Enum):
    """
    Always `file_citation`.
    """

    file_citation = 'file_citation'


class FileCitation(BaseModel):
    file_id: str
    """
    The ID of the specific File the citation is from.
    """


class MessageContentTextAnnotationsFileCitationObject(BaseModel):
    """
    A citation within the message that points to a specific quote from a specific File associated with the assistant or the message. Generated when the assistant uses the "file_search" tool to search files.
    """

    type: Type31
    """
    Always `file_citation`.
    """
    text: str
    """
    The text in the message content that needs to be replaced.
    """
    file_citation: FileCitation
    start_index: int = Field(..., ge=0)
    end_index: int = Field(..., ge=0)


class Type32(str, Enum):
    """
    Always `file_path`.
    """

    file_path = 'file_path'


class FilePath(BaseModel):
    file_id: str
    """
    The ID of the file that was generated.
    """


class MessageContentTextAnnotationsFilePathObject(BaseModel):
    """
    A URL for the file that's generated when the assistant used the `code_interpreter` tool to generate a file.
    """

    type: Type32
    """
    Always `file_path`.
    """
    text: str
    """
    The text in the message content that needs to be replaced.
    """
    file_path: FilePath
    start_index: int = Field(..., ge=0)
    end_index: int = Field(..., ge=0)


class Text(BaseModel):
    value: str
    """
    The data that makes up the text.
    """
    annotations: List[
        Union[
            MessageContentTextAnnotationsFileCitationObject,
            MessageContentTextAnnotationsFilePathObject,
        ]
    ]


class MessageContentTextObject(BaseModel):
    """
    The text content that is part of a message.
    """

    type: Type22
    """
    Always `text`.
    """
    text: Text


class ImageFile1(BaseModel):
    file_id: Optional[str] = None
    """
    The [File](/docs/api-reference/files) ID of the image in the message content. Set `purpose="vision"` when uploading the File if you need to later display the file content.
    """
    detail: Detail1 = 'auto'
    """
    Specifies the detail level of the image if specified by the user. `low` uses fewer tokens, you can opt in to high resolution using `high`.
    """


class MessageDeltaContentImageFileObject(BaseModel):
    """
    References an image [File](/docs/api-reference/files) in the content of a message.
    """

    index: int
    """
    The index of the content part in the message.
    """
    type: Type28
    """
    Always `image_file`.
    """
    image_file: Optional[ImageFile1] = None


class Detail4(str, Enum):
    """
    Specifies the detail level of the image. `low` uses fewer tokens, you can opt in to high resolution using `high`.
    """

    auto = 'auto'
    low = 'low'
    high = 'high'


class ImageUrl3(BaseModel):
    url: Optional[str] = None
    """
    The URL of the image, must be a supported image types: jpeg, jpg, png, gif, webp.
    """
    detail: Detail4 = 'auto'
    """
    Specifies the detail level of the image. `low` uses fewer tokens, you can opt in to high resolution using `high`.
    """


class MessageDeltaContentImageUrlObject(BaseModel):
    """
    References an image URL in the content of a message.
    """

    index: int
    """
    The index of the content part in the message.
    """
    type: Type21
    """
    Always `image_url`.
    """
    image_url: Optional[ImageUrl3] = None


class MessageDeltaContentRefusalObject(BaseModel):
    """
    The refusal content that is part of a message.
    """

    index: int
    """
    The index of the refusal part in the message.
    """
    type: Type30
    """
    Always `refusal`.
    """
    refusal: Optional[str] = None


class FileCitation1(BaseModel):
    file_id: Optional[str] = None
    """
    The ID of the specific File the citation is from.
    """
    quote: Optional[str] = None
    """
    The specific quote in the file.
    """


class MessageDeltaContentTextAnnotationsFileCitationObject(BaseModel):
    """
    A citation within the message that points to a specific quote from a specific File associated with the assistant or the message. Generated when the assistant uses the "file_search" tool to search files.
    """

    index: int
    """
    The index of the annotation in the text content part.
    """
    type: Type31
    """
    Always `file_citation`.
    """
    text: Optional[str] = None
    """
    The text in the message content that needs to be replaced.
    """
    file_citation: Optional[FileCitation1] = None
    start_index: Optional[int] = Field(None, ge=0)
    end_index: Optional[int] = Field(None, ge=0)


class FilePath1(BaseModel):
    file_id: Optional[str] = None
    """
    The ID of the file that was generated.
    """


class MessageDeltaContentTextAnnotationsFilePathObject(BaseModel):
    """
    A URL for the file that's generated when the assistant used the `code_interpreter` tool to generate a file.
    """

    index: int
    """
    The index of the annotation in the text content part.
    """
    type: Type32
    """
    Always `file_path`.
    """
    text: Optional[str] = None
    """
    The text in the message content that needs to be replaced.
    """
    file_path: Optional[FilePath1] = None
    start_index: Optional[int] = Field(None, ge=0)
    end_index: Optional[int] = Field(None, ge=0)


class Text1(BaseModel):
    value: Optional[str] = None
    """
    The data that makes up the text.
    """
    annotations: Optional[
        List[
            Union[
                MessageDeltaContentTextAnnotationsFileCitationObject,
                MessageDeltaContentTextAnnotationsFilePathObject,
            ]
        ]
    ] = None


class MessageDeltaContentTextObject(BaseModel):
    """
    The text content that is part of a message.
    """

    index: int
    """
    The index of the content part in the message.
    """
    type: Type22
    """
    Always `text`.
    """
    text: Optional[Text1] = None


class Object27(str, Enum):
    """
    The object type, which is always `thread.message.delta`.
    """

    thread_message_delta = 'thread.message.delta'


class Role10(str, Enum):
    """
    The entity that produced the message. One of `user` or `assistant`.
    """

    user = 'user'
    assistant = 'assistant'


class Delta(BaseModel):
    """
    The delta containing the fields that have changed on the Message.
    """

    role: Optional[Role10] = None
    """
    The entity that produced the message. One of `user` or `assistant`.
    """
    content: Optional[
        List[
            Union[
                MessageDeltaContentImageFileObject,
                MessageDeltaContentTextObject,
                MessageDeltaContentRefusalObject,
                MessageDeltaContentImageUrlObject,
            ]
        ]
    ] = None
    """
    The content of the message in array of text and/or images.
    """


class MessageDeltaObject(BaseModel):
    """
    Represents a message delta i.e. any changed fields on a message during streaming.

    """

    id: str
    """
    The identifier of the message, which can be referenced in API endpoints.
    """
    object: Object27
    """
    The object type, which is always `thread.message.delta`.
    """
    delta: Delta
    """
    The delta containing the fields that have changed on the Message.
    """


class Object28(str, Enum):
    """
    The object type, which is always `thread.message`.
    """

    thread_message = 'thread.message'


class Status3(str, Enum):
    """
    The status of the message, which can be either `in_progress`, `incomplete`, or `completed`.
    """

    in_progress = 'in_progress'
    incomplete = 'incomplete'
    completed = 'completed'


class Reason(str, Enum):
    """
    The reason the message is incomplete.
    """

    content_filter = 'content_filter'
    max_tokens = 'max_tokens'
    run_cancelled = 'run_cancelled'
    run_expired = 'run_expired'
    run_failed = 'run_failed'


class IncompleteDetails(BaseModel):
    """
    On an incomplete message, details about why the message is incomplete.
    """

    reason: Reason
    """
    The reason the message is incomplete.
    """


class MessageObject(BaseModel):
    """
    Represents a message within a [thread](/docs/api-reference/threads).
    """

    id: str
    """
    The identifier, which can be referenced in API endpoints.
    """
    object: Object28
    """
    The object type, which is always `thread.message`.
    """
    created_at: int
    """
    The Unix timestamp (in seconds) for when the message was created.
    """
    thread_id: str
    """
    The [thread](/docs/api-reference/threads) ID that this message belongs to.
    """
    status: Status3
    """
    The status of the message, which can be either `in_progress`, `incomplete`, or `completed`.
    """
    incomplete_details: Optional[IncompleteDetails] = Field(None)
    """
    On an incomplete message, details about why the message is incomplete.
    """
    completed_at: Optional[int] = Field(None)
    """
    The Unix timestamp (in seconds) for when the message was completed.
    """
    incomplete_at: Optional[int] = Field(None)
    """
    The Unix timestamp (in seconds) for when the message was marked as incomplete.
    """
    role: Role10
    """
    The entity that produced the message. One of `user` or `assistant`.
    """
    content: List[
        Union[
            MessageContentImageFileObject,
            MessageContentImageUrlObject,
            MessageContentTextObject,
            MessageContentRefusalObject,
        ]
    ]
    """
    The content of the message in array of text and/or images.
    """
    assistant_id: Optional[str] = Field(None)
    """
    If applicable, the ID of the [assistant](/docs/api-reference/assistants) that authored this message.
    """
    run_id: Optional[str] = Field(None)
    """
    The ID of the [run](/docs/api-reference/runs) associated with the creation of this message. Value is `null` when messages are created manually using the create message or create thread endpoints.
    """
    attachments: Optional[List[Attachment]] = Field(None)
    """
    A list of files attached to the message, and the tools they were added to.
    """
    metadata: Optional[Dict[str, Any]] = Field(None)
    """
    Set of 16 key-value pairs that can be attached to an object. This can be useful for storing additional information about the object in a structured format. Keys can be a maximum of 64 characters long and values can be a maximum of 512 characters long.

    """


class MessageRequestContentTextObject(BaseModel):
    """
    The text content that is part of a message.
    """

    type: Type22
    """
    Always `text`.
    """
    text: str
    """
    Text content to be sent to the model
    """


class Event2(str, Enum):
    thread_message_created = 'thread.message.created'


class MessageStreamEvent1(BaseModel):
    """
    Occurs when a [message](/docs/api-reference/messages/object) is created.
    """

    event: Event2
    data: MessageObject


class Event3(str, Enum):
    thread_message_in_progress = 'thread.message.in_progress'


class MessageStreamEvent2(BaseModel):
    """
    Occurs when a [message](/docs/api-reference/messages/object) moves to an `in_progress` state.
    """

    event: Event3
    data: MessageObject


class Event4(str, Enum):
    thread_message_delta = 'thread.message.delta'


class MessageStreamEvent3(BaseModel):
    """
    Occurs when parts of a [Message](/docs/api-reference/messages/object) are being streamed.
    """

    event: Event4
    data: MessageDeltaObject


class Event5(str, Enum):
    thread_message_completed = 'thread.message.completed'


class MessageStreamEvent4(BaseModel):
    """
    Occurs when a [message](/docs/api-reference/messages/object) is completed.
    """

    event: Event5
    data: MessageObject


class Event6(str, Enum):
    thread_message_incomplete = 'thread.message.incomplete'


class MessageStreamEvent5(BaseModel):
    """
    Occurs when a [message](/docs/api-reference/messages/object) ends before it is completed.
    """

    event: Event6
    data: MessageObject


class MessageStreamEvent(
    RootModel[
        Union[
            MessageStreamEvent1,
            MessageStreamEvent2,
            MessageStreamEvent3,
            MessageStreamEvent4,
            MessageStreamEvent5,
        ]
    ]
):
    root: Union[
        MessageStreamEvent1,
        MessageStreamEvent2,
        MessageStreamEvent3,
        MessageStreamEvent4,
        MessageStreamEvent5,
    ]


class Object29(str, Enum):
    """
    The object type, which is always "model".
    """

    model = 'model'


class ModelModel(BaseModel):
    """
    Describes an OpenAI model offering that can be used with the API.
    """

    id: str
    """
    The model identifier, which can be referenced in the API endpoints.
    """
    created: int
    """
    The Unix timestamp (in seconds) when the model was created.
    """
    object: Object29
    """
    The object type, which is always "model".
    """
    owned_by: str
    """
    The organization that owns the model.
    """


class CodeInterpreter4(BaseModel):
    file_ids: List[str] = Field([], max_length=20)
    """
    Overrides the list of [file](/docs/api-reference/files) IDs made available to the `code_interpreter` tool. There can be a maximum of 20 files associated with the tool.

    """


class FileSearch7(BaseModel):
    vector_store_ids: Optional[List[str]] = Field(None, max_length=1)
    """
    Overrides the [vector store](/docs/api-reference/vector-stores/object) attached to this assistant. There can be a maximum of 1 vector store attached to the assistant.

    """


class ToolResources4(BaseModel):
    """
    A set of resources that are used by the assistant's tools. The resources are specific to the type of tool. For example, the `code_interpreter` tool requires a list of file IDs, while the `file_search` tool requires a list of vector store IDs.

    """

    code_interpreter: Optional[CodeInterpreter4] = None
    file_search: Optional[FileSearch7] = None


class ModifyMessageRequest(BaseModel):
    model_config = ConfigDict(
        extra='forbid',
    )
    metadata: Optional[Dict[str, Any]] = None
    """
    Set of 16 key-value pairs that can be attached to an object. This can be useful for storing additional information about the object in a structured format. Keys can be a maximum of 64 characters long and values can be a maximum of 512 characters long.

    """


class ModifyRunRequest(ModifyMessageRequest):
    pass


class CodeInterpreter5(CodeInterpreter1):
    pass


class FileSearch8(BaseModel):
    vector_store_ids: Optional[List[str]] = Field(None, max_length=1)
    """
    The [vector store](/docs/api-reference/vector-stores/object) attached to this thread. There can be a maximum of 1 vector store attached to the thread.

    """


class ToolResources5(BaseModel):
    """
    A set of resources that are made available to the assistant's tools in this thread. The resources are specific to the type of tool. For example, the `code_interpreter` tool requires a list of file IDs, while the `file_search` tool requires a list of vector store IDs.

    """

    code_interpreter: Optional[CodeInterpreter5] = None
    file_search: Optional[FileSearch8] = None


class ModifyThreadRequest(BaseModel):
    model_config = ConfigDict(
        extra='forbid',
    )
    tool_resources: Optional[ToolResources5] = None
    """
    A set of resources that are made available to the assistant's tools in this thread. The resources are specific to the type of tool. For example, the `code_interpreter` tool requires a list of file IDs, while the `file_search` tool requires a list of vector store IDs.

    """
    metadata: Optional[Dict[str, Any]] = None
    """
    Set of 16 key-value pairs that can be attached to an object. This can be useful for storing additional information about the object in a structured format. Keys can be a maximum of 64 characters long and values can be a maximum of 512 characters long.

    """


class Object30(str, Enum):
    """
    The object type, which is always `file`.
    """

    file = 'file'


class Purpose2(str, Enum):
    """
    The intended purpose of the file. Supported values are `assistants`, `assistants_output`, `batch`, `batch_output`, `fine-tune`, `fine-tune-results` and `vision`.
    """

    assistants = 'assistants'
    assistants_output = 'assistants_output'
    batch = 'batch'
    batch_output = 'batch_output'
    fine_tune = 'fine-tune'
    fine_tune_results = 'fine-tune-results'
    vision = 'vision'


class Status4(str, Enum):
    """
    Deprecated. The current status of the file, which can be either `uploaded`, `processed`, or `error`.
    """

    uploaded = 'uploaded'
    processed = 'processed'
    error = 'error'


class OpenAIFile(BaseModel):
    """
    The `File` object represents a document that has been uploaded to OpenAI.
    """

    id: str
    """
    The file identifier, which can be referenced in the API endpoints.
    """
    bytes: int
    """
    The size of the file, in bytes.
    """
    created_at: int
    """
    The Unix timestamp (in seconds) for when the file was created.
    """
    filename: str
    """
    The name of the file.
    """
    object: Object30
    """
    The object type, which is always `file`.
    """
    purpose: Purpose2
    """
    The intended purpose of the file. Supported values are `assistants`, `assistants_output`, `batch`, `batch_output`, `fine-tune`, `fine-tune-results` and `vision`.
    """
    status: Status4
    """
    Deprecated. The current status of the file, which can be either `uploaded`, `processed`, or `error`.
    """
    status_details: Optional[str] = None
    """
    Deprecated. For details on why a fine-tuning training file failed validation, see the `error` field on `fine_tuning.job`.
    """


class Type41(str, Enum):
    """
    Always `other`.
    """

    other = 'other'


class OtherChunkingStrategyResponseParam(BaseModel):
    """
    This is returned when the chunking strategy is unknown. Typically, this is because the file was indexed before the `chunking_strategy` concept was introduced in the API.
    """

    model_config = ConfigDict(
        extra='forbid',
    )
    type: Type41
    """
    Always `other`.
    """


class ParallelToolCalls(RootModel[bool]):
    root: bool
    """
    Whether to enable [parallel function calling](/docs/guides/function-calling/parallel-function-calling) during tool use.
    """


class Object31(str, Enum):
    """
    The object type, which is always `organization.project`
    """

    organization_project = 'organization.project'


class Status5(str, Enum):
    """
    `active` or `archived`
    """

    active = 'active'
    archived = 'archived'


class Project1(BaseModel):
    """
    Represents an individual project.
    """

    id: str
    """
    The identifier, which can be referenced in API endpoints
    """
    object: Object31
    """
    The object type, which is always `organization.project`
    """
    name: str
    """
    The name of the project. This appears in reporting.
    """
    created_at: int
    """
    The Unix timestamp (in seconds) of when the project was created.
    """
    archived_at: Optional[int] = None
    """
    The Unix timestamp (in seconds) of when the project was archived or `null`.
    """
    status: Status5
    """
    `active` or `archived`
    """


class Object32(str, Enum):
    """
    The object type, which is always `organization.project.api_key`
    """

    organization_project_api_key = 'organization.project.api_key'


class Type42(str, Enum):
    """
    `user` or `service_account`
    """

    user = 'user'
    service_account = 'service_account'


class Object33(str, Enum):
    organization_project_api_key_deleted = 'organization.project.api_key.deleted'


class ProjectApiKeyDeleteResponse(BaseModel):
    object: Object33
    id: str
    deleted: bool


class ProjectCreateRequest(BaseModel):
    name: str
    """
    The friendly name of the project, this name appears in reports.
    """


class ProjectListResponse(BaseModel):
    object: Object20
    data: List[Project1]
    first_id: str
    last_id: str
    has_more: bool


class Object36(str, Enum):
    """
    The object type, which is always `organization.project.service_account`
    """

    organization_project_service_account = 'organization.project.service_account'


class Role12(str, Enum):
    """
    `owner` or `member`
    """

    owner = 'owner'
    member = 'member'


class ProjectServiceAccount(BaseModel):
    """
    Represents an individual service account in a project.
    """

    object: Object36
    """
    The object type, which is always `organization.project.service_account`
    """
    id: str
    """
    The identifier, which can be referenced in API endpoints
    """
    name: str
    """
    The name of the service account
    """
    role: Role12
    """
    `owner` or `member`
    """
    created_at: int
    """
    The Unix timestamp (in seconds) of when the service account was created
    """


class Object37(str, Enum):
    """
    The object type, which is always `organization.project.service_account.api_key`
    """

    organization_project_service_account_api_key = (
        'organization.project.service_account.api_key'
    )


class ProjectServiceAccountApiKey(BaseModel):
    object: Object37
    """
    The object type, which is always `organization.project.service_account.api_key`
    """
    value: str
    name: str
    created_at: int
    id: str


class ProjectServiceAccountCreateRequest(BaseModel):
    name: str
    """
    The name of the service account being created.
    """


class Object38(str, Enum):
    organization_project_service_account = 'organization.project.service_account'


class Role13(str, Enum):
    """
    Service accounts can only have one role of type `member`
    """

    member = 'member'


class ProjectServiceAccountCreateResponse(BaseModel):
    object: Object38
    id: str
    name: str
    role: Role13
    """
    Service accounts can only have one role of type `member`
    """
    created_at: int
    api_key: ProjectServiceAccountApiKey


class Object39(str, Enum):
    organization_project_service_account_deleted = (
        'organization.project.service_account.deleted'
    )


class ProjectServiceAccountDeleteResponse(BaseModel):
    object: Object39
    id: str
    deleted: bool


class ProjectServiceAccountListResponse(BaseModel):
    object: Object20
    data: List[ProjectServiceAccount]
    first_id: str
    last_id: str
    has_more: bool


class ProjectUpdateRequest(BaseModel):
    name: str
    """
    The updated name of the project, this name appears in reports.
    """


class Object41(str, Enum):
    """
    The object type, which is always `organization.project.user`
    """

    organization_project_user = 'organization.project.user'


class ProjectUser(BaseModel):
    """
    Represents an individual user in a project.
    """

    object: Object41
    """
    The object type, which is always `organization.project.user`
    """
    id: str
    """
    The identifier, which can be referenced in API endpoints
    """
    name: str
    """
    The name of the user
    """
    email: str
    """
    The email address of the user
    """
    role: Role12
    """
    `owner` or `member`
    """
    added_at: int
    """
    The Unix timestamp (in seconds) of when the project was added.
    """


class ProjectUserCreateRequest(BaseModel):
    user_id: str
    """
    The ID of the user.
    """
    role: Role12
    """
    `owner` or `member`
    """


class Object42(str, Enum):
    organization_project_user_deleted = 'organization.project.user.deleted'


class ProjectUserDeleteResponse(BaseModel):
    object: Object42
    id: str
    deleted: bool


class ProjectUserListResponse(BaseModel):
    object: str
    data: List[ProjectUser]
    first_id: str
    last_id: str
    has_more: bool


class ProjectUserUpdateRequest(BaseModel):
    role: Role12
    """
    `owner` or `member`
    """


class ContentItem(BaseModel):
    type: Optional[str] = None
    """
    The content type ("input_text", "input_audio", "text", "audio").
    """
    text: Optional[str] = None
    """
    The text content.
    """
    audio: Optional[str] = None
    """
    Base64-encoded audio bytes.
    """
    transcript: Optional[str] = None
    """
    The transcript of the audio.
    """


class Item(BaseModel):
    """
    The item to add to the conversation.
    """

    id: Optional[str] = None
    """
    The unique ID of the item.
    """
    type: Optional[str] = None
    """
    The type of the item ("message", "function_call", "function_call_output").
    """
    status: Optional[str] = None
    """
    The status of the item ("completed", "in_progress", "incomplete").
    """
    role: Optional[str] = None
    """
    The role of the message sender ("user", "assistant", "system").
    """
    content: Optional[List[ContentItem]] = None
    """
    The content of the message.
    """
    call_id: Optional[str] = None
    """
    The ID of the function call (for "function_call" items).
    """
    name: Optional[str] = None
    """
    The name of the function being called (for "function_call" items).
    """
    arguments: Optional[str] = None
    """
    The arguments of the function call (for "function_call" items).
    """
    output: Optional[str] = None
    """
    The output of the function call (for "function_call_output" items).
    """


class RealtimeClientEventConversationItemCreate(BaseModel):
    """
    Send this event when adding an item to the conversation.
    """

    event_id: Optional[str] = None
    """
    Optional client-generated ID used to identify this event.
    """
    type: str
    """
    The event type, must be "conversation.item.create".
    """
    previous_item_id: Optional[str] = None
    """
    The ID of the preceding item after which the new item will be inserted.
    """
    item: Item
    """
    The item to add to the conversation.
    """


class RealtimeClientEventConversationItemDelete(BaseModel):
    """
    Send this event when you want to remove any item from the conversation history.
    """

    event_id: Optional[str] = None
    """
    Optional client-generated ID used to identify this event.
    """
    type: str
    """
    The event type, must be "conversation.item.delete".
    """
    item_id: str
    """
    The ID of the item to delete.
    """


class RealtimeClientEventConversationItemTruncate(BaseModel):
    """
    Send this event when you want to truncate a previous assistant message’s audio.
    """

    event_id: Optional[str] = None
    """
    Optional client-generated ID used to identify this event.
    """
    type: str
    """
    The event type, must be "conversation.item.truncate".
    """
    item_id: str
    """
    The ID of the assistant message item to truncate.
    """
    content_index: int
    """
    The index of the content part to truncate.
    """
    audio_end_ms: int
    """
    Inclusive duration up to which audio is truncated, in milliseconds.
    """


class RealtimeClientEventInputAudioBufferAppend(BaseModel):
    """
    Send this event to append audio bytes to the input audio buffer.
    """

    event_id: Optional[str] = None
    """
    Optional client-generated ID used to identify this event.
    """
    type: str
    """
    The event type, must be "input_audio_buffer.append".
    """
    audio: str
    """
    Base64-encoded audio bytes.
    """


class RealtimeClientEventInputAudioBufferClear(BaseModel):
    """
    Send this event to clear the audio bytes in the buffer.
    """

    event_id: Optional[str] = None
    """
    Optional client-generated ID used to identify this event.
    """
    type: str
    """
    The event type, must be "input_audio_buffer.clear".
    """


class RealtimeClientEventInputAudioBufferCommit(BaseModel):
    """
    Send this event to commit audio bytes to a user message.
    """

    event_id: Optional[str] = None
    """
    Optional client-generated ID used to identify this event.
    """
    type: str
    """
    The event type, must be "input_audio_buffer.commit".
    """


class RealtimeClientEventResponseCancel(BaseModel):
    """
    Send this event to cancel an in-progress response.
    """

    event_id: Optional[str] = None
    """
    Optional client-generated ID used to identify this event.
    """
    type: str
    """
    The event type, must be "response.cancel".
    """


class Tool(BaseModel):
    type: Optional[str] = None
    """
    The type of the tool.
    """
    name: Optional[str] = None
    """
    The name of the function.
    """
    description: Optional[str] = None
    """
    The description of the function.
    """
    parameters: Optional[Dict[str, Any]] = None
    """
    Parameters of the function in JSON Schema.
    """


class MaxOutputTokens(str, Enum):
    """
    Maximum number of output tokens for a single assistant response, inclusive of tool calls. Provide an integer between 1 and 4096 to limit output tokens, or "inf" for the maximum available tokens for a given model. Defaults to "inf".
    """

    inf = 'inf'


class Response1(BaseModel):
    """
    Configuration for the response.
    """

    modalities: Optional[List[str]] = None
    """
    The modalities for the response.
    """
    instructions: Optional[str] = None
    """
    Instructions for the model.
    """
    voice: Optional[str] = None
    """
    The voice the model uses to respond - one of `alloy`, `echo`, or `shimmer`.
    """
    output_audio_format: Optional[str] = None
    """
    The format of output audio.
    """
    tools: Optional[List[Tool]] = None
    """
    Tools (functions) available to the model.
    """
    tool_choice: Optional[str] = None
    """
    How the model chooses tools.
    """
    temperature: Optional[float] = None
    """
    Sampling temperature.
    """
    max_output_tokens: Optional[Union[int, MaxOutputTokens]] = None
    """
    Maximum number of output tokens for a single assistant response, inclusive of tool calls. Provide an integer between 1 and 4096 to limit output tokens, or "inf" for the maximum available tokens for a given model. Defaults to "inf".
    """


class RealtimeClientEventResponseCreate(BaseModel):
    """
    Send this event to trigger a response generation.
    """

    event_id: Optional[str] = None
    """
    Optional client-generated ID used to identify this event.
    """
    type: str
    """
    The event type, must be "response.create".
    """
    response: Response1
    """
    Configuration for the response.
    """


class InputAudioTranscription(BaseModel):
    """
    Configuration for input audio transcription. Can be set to `null` to turn off.
    """

    model: Optional[str] = None
    """
    The model to use for transcription (e.g., "whisper-1").
    """


class TurnDetection(BaseModel):
    """
    Configuration for turn detection. Can be set to `null` to turn off.
    """

    type: Optional[str] = None
    """
    Type of turn detection, only "server_vad" is currently supported.
    """
    threshold: Optional[float] = None
    """
    Activation threshold for VAD (0.0 to 1.0).
    """
    prefix_padding_ms: Optional[int] = None
    """
    Amount of audio to include before speech starts (in milliseconds).
    """
    silence_duration_ms: Optional[int] = None
    """
    Duration of silence to detect speech stop (in milliseconds).
    """


class Tool1(BaseModel):
    type: Optional[str] = None
    """
    The type of the tool, e.g., "function".
    """
    name: Optional[str] = None
    """
    The name of the function.
    """
    description: Optional[str] = None
    """
    The description of the function.
    """
    parameters: Optional[Dict[str, Any]] = None
    """
    Parameters of the function in JSON Schema.
    """


class Session(BaseModel):
    """
    Session configuration to update.
    """

    modalities: Optional[List[str]] = None
    """
    The set of modalities the model can respond with. To disable audio, set this to ["text"].
    """
    instructions: Optional[str] = None
    """
    The default system instructions prepended to model calls.
    """
    voice: Optional[str] = None
    """
    The voice the model uses to respond - one of `alloy`, `echo`, or  `shimmer`. Cannot be changed once the model has responded with audio  at least once.
    """
    input_audio_format: Optional[str] = None
    """
    The format of input audio. Options are "pcm16", "g711_ulaw", or "g711_alaw".
    """
    output_audio_format: Optional[str] = None
    """
    The format of output audio. Options are "pcm16", "g711_ulaw", or "g711_alaw".
    """
    input_audio_transcription: Optional[InputAudioTranscription] = None
    """
    Configuration for input audio transcription. Can be set to `null` to turn off.
    """
    turn_detection: Optional[TurnDetection] = None
    """
    Configuration for turn detection. Can be set to `null` to turn off.
    """
    tools: Optional[List[Tool1]] = None
    """
    Tools (functions) available to the model.
    """
    tool_choice: Optional[str] = None
    """
    How the model chooses tools. Options are "auto", "none", "required", or specify a function.
    """
    temperature: Optional[float] = None
    """
    Sampling temperature for the model.
    """
    max_output_tokens: Optional[Union[int, MaxOutputTokens]] = None
    """
    Maximum number of output tokens for a single assistant response, inclusive of tool calls. Provide an integer between 1 and 4096 to limit output tokens, or "inf" for the maximum available tokens for a given model. Defaults to "inf".
    """


class RealtimeClientEventSessionUpdate(BaseModel):
    """
    Send this event to update the session’s default configuration.
    """

    event_id: Optional[str] = None
    """
    Optional client-generated ID used to identify this event.
    """
    type: str
    """
    The event type, must be "session.update".
    """
    session: Session
    """
    Session configuration to update.
    """


class Conversation(BaseModel):
    """
    The conversation resource.
    """

    id: Optional[str] = None
    """
    The unique ID of the conversation.
    """
    object: Optional[str] = None
    """
    The object type, must be "realtime.conversation".
    """


class RealtimeServerEventConversationCreated(BaseModel):
    """
    Returned when a conversation is created. Emitted right after session creation.
    """

    event_id: str
    """
    The unique ID of the server event.
    """
    type: str
    """
    The event type, must be "conversation.created".
    """
    conversation: Conversation
    """
    The conversation resource.
    """


class ContentItem1(BaseModel):
    type: Optional[str] = None
    """
    The content type ("text", "audio", "input_text", "input_audio").
    """
    text: Optional[str] = None
    """
    The text content.
    """
    audio: Optional[str] = None
    """
    Base64-encoded audio data.
    """
    transcript: Optional[str] = None
    """
    The transcript of the audio.
    """


class Item1(BaseModel):
    """
    The item that was created.
    """

    id: Optional[str] = None
    """
    The unique ID of the item.
    """
    object: Optional[str] = None
    """
    The object type, must be "realtime.item".
    """
    type: Optional[str] = None
    """
    The type of the item ("message", "function_call", "function_call_output").
    """
    status: Optional[str] = None
    """
    The status of the item ("completed", "in_progress", "incomplete").
    """
    role: Optional[str] = None
    """
    The role associated with the item ("user", "assistant", "system").
    """
    content: Optional[List[ContentItem1]] = None
    """
    The content of the item.
    """
    call_id: Optional[str] = None
    """
    The ID of the function call (for "function_call" items).
    """
    name: Optional[str] = None
    """
    The name of the function being called.
    """
    arguments: Optional[str] = None
    """
    The arguments of the function call.
    """
    output: Optional[str] = None
    """
    The output of the function call (for "function_call_output" items).
    """


class RealtimeServerEventConversationItemCreated(BaseModel):
    """
    Returned when a conversation item is created.
    """

    event_id: str
    """
    The unique ID of the server event.
    """
    type: str
    """
    The event type, must be "conversation.item.created".
    """
    previous_item_id: str
    """
    The ID of the preceding item.
    """
    item: Item1
    """
    The item that was created.
    """


class RealtimeServerEventConversationItemDeleted(BaseModel):
    """
    Returned when an item in the conversation is deleted.
    """

    event_id: str
    """
    The unique ID of the server event.
    """
    type: str
    """
    The event type, must be "conversation.item.deleted".
    """
    item_id: str
    """
    The ID of the item that was deleted.
    """


class RealtimeServerEventConversationItemInputAudioTranscriptionCompleted(BaseModel):
    """
    Returned when input audio transcription is enabled and a transcription succeeds.
    """

    event_id: str
    """
    The unique ID of the server event.
    """
    type: str
    """
    The event type, must be "conversation.item.input_audio_transcription.completed".
    """
    item_id: str
    """
    The ID of the user message item.
    """
    content_index: int
    """
    The index of the content part containing the audio.
    """
    transcript: str
    """
    The transcribed text.
    """


class Error3(BaseModel):
    """
    Details of the transcription error.
    """

    type: Optional[str] = None
    """
    The type of error.
    """
    code: Optional[str] = None
    """
    Error code, if any.
    """
    message: Optional[str] = None
    """
    A human-readable error message.
    """
    param: Optional[str] = None
    """
    Parameter related to the error, if any.
    """


class RealtimeServerEventConversationItemInputAudioTranscriptionFailed(BaseModel):
    """
    Returned when input audio transcription is configured, and a transcription request for a user message failed.
    """

    event_id: str
    """
    The unique ID of the server event.
    """
    type: str
    """
    The event type, must be "conversation.item.input_audio_transcription.failed".
    """
    item_id: str
    """
    The ID of the user message item.
    """
    content_index: int
    """
    The index of the content part containing the audio.
    """
    error: Error3
    """
    Details of the transcription error.
    """


class RealtimeServerEventConversationItemTruncated(BaseModel):
    """
    Returned when an earlier assistant audio message item is truncated by the client.
    """

    event_id: str
    """
    The unique ID of the server event.
    """
    type: str
    """
    The event type, must be "conversation.item.truncated".
    """
    item_id: str
    """
    The ID of the assistant message item that was truncated.
    """
    content_index: int
    """
    The index of the content part that was truncated.
    """
    audio_end_ms: int
    """
    The duration up to which the audio was truncated, in milliseconds.
    """


class Error4(BaseModel):
    """
    Details of the error.
    """

    type: Optional[str] = None
    """
    The type of error (e.g., "invalid_request_error", "server_error").
    """
    code: Optional[str] = None
    """
    Error code, if any.
    """
    message: Optional[str] = None
    """
    A human-readable error message.
    """
    param: Optional[str] = None
    """
    Parameter related to the error, if any.
    """
    event_id: Optional[str] = None
    """
    The event_id of the client event that caused the error, if applicable.
    """


class RealtimeServerEventError(BaseModel):
    """
    Returned when an error occurs.
    """

    event_id: str
    """
    The unique ID of the server event.
    """
    type: str
    """
    The event type, must be "error".
    """
    error: Error4
    """
    Details of the error.
    """


class RealtimeServerEventInputAudioBufferCleared(BaseModel):
    """
    Returned when the input audio buffer is cleared by the client.
    """

    event_id: str
    """
    The unique ID of the server event.
    """
    type: str
    """
    The event type, must be "input_audio_buffer.cleared".
    """


class RealtimeServerEventInputAudioBufferCommitted(BaseModel):
    """
    Returned when an input audio buffer is committed, either by the client or automatically in server VAD mode.
    """

    event_id: str
    """
    The unique ID of the server event.
    """
    type: str
    """
    The event type, must be "input_audio_buffer.committed".
    """
    previous_item_id: str
    """
    The ID of the preceding item after which the new item will be inserted.
    """
    item_id: str
    """
    The ID of the user message item that will be created.
    """


class RealtimeServerEventInputAudioBufferSpeechStarted(BaseModel):
    """
    Returned in server turn detection mode when speech is detected.
    """

    event_id: str
    """
    The unique ID of the server event.
    """
    type: str
    """
    The event type, must be "input_audio_buffer.speech_started".
    """
    audio_start_ms: int
    """
    Milliseconds since the session started when speech was detected.
    """
    item_id: str
    """
    The ID of the user message item that will be created when speech stops.
    """


class RealtimeServerEventInputAudioBufferSpeechStopped(BaseModel):
    """
    Returned in server turn detection mode when speech stops.
    """

    event_id: str
    """
    The unique ID of the server event.
    """
    type: str
    """
    The event type, must be "input_audio_buffer.speech_stopped".
    """
    audio_end_ms: int
    """
    Milliseconds since the session started when speech stopped.
    """
    item_id: str
    """
    The ID of the user message item that will be created.
    """


class RateLimit(BaseModel):
    name: Optional[str] = None
    """
    The name of the rate limit ("requests", "tokens", "input_tokens", "output_tokens").
    """
    limit: Optional[int] = None
    """
    The maximum allowed value for the rate limit.
    """
    remaining: Optional[int] = None
    """
    The remaining value before the limit is reached.
    """
    reset_seconds: Optional[float] = None
    """
    Seconds until the rate limit resets.
    """


class RealtimeServerEventRateLimitsUpdated(BaseModel):
    """
    Emitted after every "response.done" event to indicate the updated rate limits.
    """

    event_id: str
    """
    The unique ID of the server event.
    """
    type: str
    """
    The event type, must be "rate_limits.updated".
    """
    rate_limits: List[RateLimit]
    """
    List of rate limit information.
    """


class RealtimeServerEventResponseAudioDelta(BaseModel):
    """
    Returned when the model-generated audio is updated.
    """

    event_id: str
    """
    The unique ID of the server event.
    """
    type: str
    """
    The event type, must be "response.audio.delta".
    """
    response_id: str
    """
    The ID of the response.
    """
    item_id: str
    """
    The ID of the item.
    """
    output_index: int
    """
    The index of the output item in the response.
    """
    content_index: int
    """
    The index of the content part in the item's content array.
    """
    delta: str
    """
    Base64-encoded audio data delta.
    """


class RealtimeServerEventResponseAudioDone(BaseModel):
    """
    Returned when the model-generated audio is done. Also emitted when a Response is interrupted, incomplete, or cancelled.
    """

    event_id: str
    """
    The unique ID of the server event.
    """
    type: str
    """
    The event type, must be "response.audio.done".
    """
    response_id: str
    """
    The ID of the response.
    """
    item_id: str
    """
    The ID of the item.
    """
    output_index: int
    """
    The index of the output item in the response.
    """
    content_index: int
    """
    The index of the content part in the item's content array.
    """


class RealtimeServerEventResponseAudioTranscriptDelta(BaseModel):
    """
    Returned when the model-generated transcription of audio output is updated.
    """

    event_id: str
    """
    The unique ID of the server event.
    """
    type: str
    """
    The event type, must be "response.audio_transcript.delta".
    """
    response_id: str
    """
    The ID of the response.
    """
    item_id: str
    """
    The ID of the item.
    """
    output_index: int
    """
    The index of the output item in the response.
    """
    content_index: int
    """
    The index of the content part in the item's content array.
    """
    delta: str
    """
    The transcript delta.
    """


class RealtimeServerEventResponseAudioTranscriptDone(BaseModel):
    """
    Returned when the model-generated transcription of audio output is done streaming. Also emitted when a Response is interrupted, incomplete, or cancelled.
    """

    event_id: str
    """
    The unique ID of the server event.
    """
    type: str
    """
    The event type, must be "response.audio_transcript.done".
    """
    response_id: str
    """
    The ID of the response.
    """
    item_id: str
    """
    The ID of the item.
    """
    output_index: int
    """
    The index of the output item in the response.
    """
    content_index: int
    """
    The index of the content part in the item's content array.
    """
    transcript: str
    """
    The final transcript of the audio.
    """


class Part(BaseModel):
    """
    The content part that was added.
    """

    type: Optional[str] = None
    """
    The content type ("text", "audio").
    """
    text: Optional[str] = None
    """
    The text content (if type is "text").
    """
    audio: Optional[str] = None
    """
    Base64-encoded audio data (if type is "audio").
    """
    transcript: Optional[str] = None
    """
    The transcript of the audio (if type is "audio").
    """


class RealtimeServerEventResponseContentPartAdded(BaseModel):
    """
    Returned when a new content part is added to an assistant message item during response generation.
    """

    event_id: str
    """
    The unique ID of the server event.
    """
    type: str
    """
    The event type, must be "response.content_part.added".
    """
    response_id: str
    """
    The ID of the response.
    """
    item_id: str
    """
    The ID of the item to which the content part was added.
    """
    output_index: int
    """
    The index of the output item in the response.
    """
    content_index: int
    """
    The index of the content part in the item's content array.
    """
    part: Part
    """
    The content part that was added.
    """


class Part1(BaseModel):
    """
    The content part that is done.
    """

    type: Optional[str] = None
    """
    The content type ("text", "audio").
    """
    text: Optional[str] = None
    """
    The text content (if type is "text").
    """
    audio: Optional[str] = None
    """
    Base64-encoded audio data (if type is "audio").
    """
    transcript: Optional[str] = None
    """
    The transcript of the audio (if type is "audio").
    """


class RealtimeServerEventResponseContentPartDone(BaseModel):
    """
    Returned when a content part is done streaming in an assistant message item. Also emitted when a Response is interrupted, incomplete, or cancelled.
    """

    event_id: str
    """
    The unique ID of the server event.
    """
    type: str
    """
    The event type, must be "response.content_part.done".
    """
    response_id: str
    """
    The ID of the response.
    """
    item_id: str
    """
    The ID of the item.
    """
    output_index: int
    """
    The index of the output item in the response.
    """
    content_index: int
    """
    The index of the content part in the item's content array.
    """
    part: Part1
    """
    The content part that is done.
    """


class Response2(BaseModel):
    """
    The response resource.
    """

    id: Optional[str] = None
    """
    The unique ID of the response.
    """
    object: Optional[str] = None
    """
    The object type, must be "realtime.response".
    """
    status: Optional[str] = None
    """
    The status of the response ("in_progress").
    """
    status_details: Optional[Dict[str, Any]] = None
    """
    Additional details about the status.
    """
    output: Optional[List[Dict[str, Any]]] = None
    """
    The list of output items generated by the response.
    """
    usage: Optional[Dict[str, Any]] = None
    """
    Usage statistics for the response.
    """


class RealtimeServerEventResponseCreated(BaseModel):
    """
    Returned when a new Response is created. The first event of response creation, where the response is in an initial state of "in_progress".
    """

    event_id: str
    """
    The unique ID of the server event.
    """
    type: str
    """
    The event type, must be "response.created".
    """
    response: Response2
    """
    The response resource.
    """


class Response3(BaseModel):
    """
    The response resource.
    """

    id: Optional[str] = None
    """
    The unique ID of the response.
    """
    object: Optional[str] = None
    """
    The object type, must be "realtime.response".
    """
    status: Optional[str] = None
    """
    The final status of the response ("completed", "cancelled", "failed", "incomplete").
    """
    status_details: Optional[Dict[str, Any]] = None
    """
    Additional details about the status.
    """
    output: Optional[List[Dict[str, Any]]] = None
    """
    The list of output items generated by the response.
    """
    usage: Optional[Dict[str, Any]] = None
    """
    Usage statistics for the response.
    """


class RealtimeServerEventResponseDone(BaseModel):
    """
    Returned when a Response is done streaming. Always emitted, no matter the final state.
    """

    event_id: str
    """
    The unique ID of the server event.
    """
    type: str
    """
    The event type, must be "response.done".
    """
    response: Response3
    """
    The response resource.
    """


class RealtimeServerEventResponseFunctionCallArgumentsDelta(BaseModel):
    """
    Returned when the model-generated function call arguments are updated.
    """

    event_id: str
    """
    The unique ID of the server event.
    """
    type: str
    """
    The event type, must be "response.function_call_arguments.delta".
    """
    response_id: str
    """
    The ID of the response.
    """
    item_id: str
    """
    The ID of the function call item.
    """
    output_index: int
    """
    The index of the output item in the response.
    """
    call_id: str
    """
    The ID of the function call.
    """
    delta: str
    """
    The arguments delta as a JSON string.
    """


class RealtimeServerEventResponseFunctionCallArgumentsDone(BaseModel):
    """
    Returned when the model-generated function call arguments are done streaming. Also emitted when a Response is interrupted, incomplete, or cancelled.
    """

    event_id: str
    """
    The unique ID of the server event.
    """
    type: str
    """
    The event type, must be "response.function_call_arguments.done".
    """
    response_id: str
    """
    The ID of the response.
    """
    item_id: str
    """
    The ID of the function call item.
    """
    output_index: int
    """
    The index of the output item in the response.
    """
    call_id: str
    """
    The ID of the function call.
    """
    arguments: str
    """
    The final arguments as a JSON string.
    """


class ContentItem2(BaseModel):
    type: Optional[str] = None
    """
    The content type ("text", "audio").
    """
    text: Optional[str] = None
    """
    The text content.
    """
    audio: Optional[str] = None
    """
    Base64-encoded audio data.
    """
    transcript: Optional[str] = None
    """
    The transcript of the audio.
    """


class Item2(BaseModel):
    """
    The item that was added.
    """

    id: Optional[str] = None
    """
    The unique ID of the item.
    """
    object: Optional[str] = None
    """
    The object type, must be "realtime.item".
    """
    type: Optional[str] = None
    """
    The type of the item ("message", "function_call", "function_call_output").
    """
    status: Optional[str] = None
    """
    The status of the item ("in_progress", "completed").
    """
    role: Optional[str] = None
    """
    The role associated with the item ("assistant").
    """
    content: Optional[List[ContentItem2]] = None
    """
    The content of the item.
    """


class RealtimeServerEventResponseOutputItemAdded(BaseModel):
    """
    Returned when a new Item is created during response generation.
    """

    event_id: str
    """
    The unique ID of the server event.
    """
    type: str
    """
    The event type, must be "response.output_item.added".
    """
    response_id: str
    """
    The ID of the response to which the item belongs.
    """
    output_index: int
    """
    The index of the output item in the response.
    """
    item: Item2
    """
    The item that was added.
    """


class Item3(BaseModel):
    """
    The completed item.
    """

    id: Optional[str] = None
    """
    The unique ID of the item.
    """
    object: Optional[str] = None
    """
    The object type, must be "realtime.item".
    """
    type: Optional[str] = None
    """
    The type of the item ("message", "function_call", "function_call_output").
    """
    status: Optional[str] = None
    """
    The final status of the item ("completed", "incomplete").
    """
    role: Optional[str] = None
    """
    The role associated with the item ("assistant").
    """
    content: Optional[List[ContentItem2]] = None
    """
    The content of the item.
    """


class RealtimeServerEventResponseOutputItemDone(BaseModel):
    """
    Returned when an Item is done streaming. Also emitted when a Response is interrupted, incomplete, or cancelled.
    """

    event_id: str
    """
    The unique ID of the server event.
    """
    type: str
    """
    The event type, must be "response.output_item.done".
    """
    response_id: str
    """
    The ID of the response to which the item belongs.
    """
    output_index: int
    """
    The index of the output item in the response.
    """
    item: Item3
    """
    The completed item.
    """


class RealtimeServerEventResponseTextDelta(BaseModel):
    """
    Returned when the text value of a "text" content part is updated.
    """

    event_id: str
    """
    The unique ID of the server event.
    """
    type: str
    """
    The event type, must be "response.text.delta".
    """
    response_id: str
    """
    The ID of the response.
    """
    item_id: str
    """
    The ID of the item.
    """
    output_index: int
    """
    The index of the output item in the response.
    """
    content_index: int
    """
    The index of the content part in the item's content array.
    """
    delta: str
    """
    The text delta.
    """


class RealtimeServerEventResponseTextDone(BaseModel):
    """
    Returned when the text value of a "text" content part is done streaming. Also emitted when a Response is interrupted, incomplete, or cancelled.
    """

    event_id: str
    """
    The unique ID of the server event.
    """
    type: str
    """
    The event type, must be "response.text.done".
    """
    response_id: str
    """
    The ID of the response.
    """
    item_id: str
    """
    The ID of the item.
    """
    output_index: int
    """
    The index of the output item in the response.
    """
    content_index: int
    """
    The index of the content part in the item's content array.
    """
    text: str
    """
    The final text content.
    """


class InputAudioTranscription1(BaseModel):
    """
    Configuration for input audio transcription.
    """

    enabled: Optional[bool] = None
    """
    Whether input audio transcription is enabled.
    """
    model: Optional[str] = None
    """
    The model used for transcription.
    """


class TurnDetection1(BaseModel):
    """
    Configuration for turn detection.
    """

    type: Optional[str] = None
    """
    The type of turn detection ("server_vad" or "none").
    """
    threshold: Optional[float] = None
    """
    Activation threshold for VAD.
    """
    prefix_padding_ms: Optional[int] = None
    """
    Audio included before speech starts (in milliseconds).
    """
    silence_duration_ms: Optional[int] = None
    """
    Duration of silence to detect speech stop (in milliseconds).
    """


class Tool2(Tool):
    pass


class MaxOutputTokens2(str, Enum):
    """
    Maximum number of output tokens.
    """

    inf = 'inf'


class Session1(BaseModel):
    """
    The session resource.
    """

    id: Optional[str] = None
    """
    The unique ID of the session.
    """
    object: Optional[str] = None
    """
    The object type, must be "realtime.session".
    """
    model: Optional[str] = None
    """
    The default model used for this session.
    """
    modalities: Optional[List[str]] = None
    """
    The set of modalities the model can respond with.
    """
    instructions: Optional[str] = None
    """
    The default system instructions.
    """
    voice: Optional[str] = None
    """
    The voice the model uses to respond - one of `alloy`, `echo`, or `shimmer`.
    """
    input_audio_format: Optional[str] = None
    """
    The format of input audio.
    """
    output_audio_format: Optional[str] = None
    """
    The format of output audio.
    """
    input_audio_transcription: Optional[InputAudioTranscription1] = None
    """
    Configuration for input audio transcription.
    """
    turn_detection: Optional[TurnDetection1] = None
    """
    Configuration for turn detection.
    """
    tools: Optional[List[Tool2]] = None
    """
    Tools (functions) available to the model.
    """
    tool_choice: Optional[str] = None
    """
    How the model chooses tools.
    """
    temperature: Optional[float] = None
    """
    Sampling temperature.
    """
    max_output_tokens: Optional[Union[int, MaxOutputTokens2]] = None
    """
    Maximum number of output tokens.
    """


class RealtimeServerEventSessionCreated(BaseModel):
    """
    Returned when a session is created. Emitted automatically when a new connection is established.
    """

    event_id: str
    """
    The unique ID of the server event.
    """
    type: str
    """
    The event type, must be "session.created".
    """
    session: Session1
    """
    The session resource.
    """


class Session2(BaseModel):
    """
    The updated session resource.
    """

    id: Optional[str] = None
    """
    The unique ID of the session.
    """
    object: Optional[str] = None
    """
    The object type, must be "realtime.session".
    """
    model: Optional[str] = None
    """
    The default model used for this session.
    """
    modalities: Optional[List[str]] = None
    """
    The set of modalities the model can respond with.
    """
    instructions: Optional[str] = None
    """
    The default system instructions.
    """
    voice: Optional[str] = None
    """
    The voice the model uses to respond - one of `alloy`, `echo`, or `shimmer`.
    """
    input_audio_format: Optional[str] = None
    """
    The format of input audio.
    """
    output_audio_format: Optional[str] = None
    """
    The format of output audio.
    """
    input_audio_transcription: Optional[InputAudioTranscription1] = None
    """
    Configuration for input audio transcription.
    """
    turn_detection: Optional[TurnDetection1] = None
    """
    Configuration for turn detection.
    """
    tools: Optional[List[Tool2]] = None
    """
    Tools (functions) available to the model.
    """
    tool_choice: Optional[str] = None
    """
    How the model chooses tools.
    """
    temperature: Optional[float] = None
    """
    Sampling temperature.
    """
    max_output_tokens: Optional[Union[int, MaxOutputTokens2]] = None
    """
    Maximum number of output tokens.
    """


class RealtimeServerEventSessionUpdated(BaseModel):
    """
    Returned when a session is updated.
    """

    event_id: str
    """
    The unique ID of the server event.
    """
    type: str
    """
    The event type, must be "session.updated".
    """
    session: Session2
    """
    The updated session resource.
    """


class Type43(str, Enum):
    """
    The type of response format being defined: `json_object`
    """

    json_object = 'json_object'


class ResponseFormatJsonObject(BaseModel):
    type: Type43
    """
    The type of response format being defined: `json_object`
    """


class Type44(str, Enum):
    """
    The type of response format being defined: `json_schema`
    """

    json_schema = 'json_schema'


class ResponseFormatJsonSchemaSchema(BaseModel):
    """
    The schema for the response format, described as a JSON Schema object.
    """

    model_config = ConfigDict(
        extra='allow',
    )


class Type45(str, Enum):
    """
    The type of response format being defined: `text`
    """

    text = 'text'


class ResponseFormatText(BaseModel):
    type: Type45
    """
    The type of response format being defined: `text`
    """


class RunCompletionUsage(BaseModel):
    """
    Usage statistics related to the run. This value will be `null` if the run is not in a terminal state (i.e. `in_progress`, `queued`, etc.).
    """

    completion_tokens: int
    """
    Number of completion tokens used over the course of the run.
    """
    prompt_tokens: int
    """
    Number of prompt tokens used over the course of the run.
    """
    total_tokens: int
    """
    Total number of tokens used (prompt + completion).
    """


class Object43(str, Enum):
    """
    The object type, which is always `thread.run`.
    """

    thread_run = 'thread.run'


class Status6(str, Enum):
    """
    The status of the run, which can be either `queued`, `in_progress`, `requires_action`, `cancelling`, `cancelled`, `failed`, `completed`, `incomplete`, or `expired`.
    """

    queued = 'queued'
    in_progress = 'in_progress'
    requires_action = 'requires_action'
    cancelling = 'cancelling'
    cancelled = 'cancelled'
    failed = 'failed'
    completed = 'completed'
    incomplete = 'incomplete'
    expired = 'expired'


class Type46(str, Enum):
    """
    For now, this is always `submit_tool_outputs`.
    """

    submit_tool_outputs = 'submit_tool_outputs'


class Code(str, Enum):
    """
    One of `server_error`, `rate_limit_exceeded`, or `invalid_prompt`.
    """

    server_error = 'server_error'
    rate_limit_exceeded = 'rate_limit_exceeded'
    invalid_prompt = 'invalid_prompt'


class LastError(BaseModel):
    """
    The last error associated with this run. Will be `null` if there are no errors.
    """

    code: Code
    """
    One of `server_error`, `rate_limit_exceeded`, or `invalid_prompt`.
    """
    message: str
    """
    A human-readable description of the error.
    """


class Reason1(str, Enum):
    """
    The reason why the run is incomplete. This will point to which specific token limit was reached over the course of the run.
    """

    max_completion_tokens = 'max_completion_tokens'
    max_prompt_tokens = 'max_prompt_tokens'


class IncompleteDetails1(BaseModel):
    """
    Details on why the run is incomplete. Will be `null` if the run is not incomplete.
    """

    reason: Optional[Reason1] = None
    """
    The reason why the run is incomplete. This will point to which specific token limit was reached over the course of the run.
    """


class RunStepCompletionUsage(BaseModel):
    """
    Usage statistics related to the run step. This value will be `null` while the run step's status is `in_progress`.
    """

    completion_tokens: int
    """
    Number of completion tokens used over the course of the run step.
    """
    prompt_tokens: int
    """
    Number of prompt tokens used over the course of the run step.
    """
    total_tokens: int
    """
    Total number of tokens used (prompt + completion).
    """


class Object44(str, Enum):
    """
    The object type, which is always `thread.run.step.delta`.
    """

    thread_run_step_delta = 'thread.run.step.delta'


class Type47(str, Enum):
    """
    Always `message_creation`.
    """

    message_creation = 'message_creation'


class MessageCreation(BaseModel):
    message_id: Optional[str] = None
    """
    The ID of the message that was created by this run step.
    """


class RunStepDeltaStepDetailsMessageCreationObject(BaseModel):
    """
    Details of the message creation by the run step.
    """

    type: Type47
    """
    Always `message_creation`.
    """
    message_creation: Optional[MessageCreation] = None


class Type48(str, Enum):
    """
    The type of tool call. This is always going to be `code_interpreter` for this type of tool call.
    """

    code_interpreter = 'code_interpreter'


class Type49(str, Enum):
    """
    Always `image`.
    """

    image = 'image'


class Image1(BaseModel):
    file_id: Optional[str] = None
    """
    The [file](/docs/api-reference/files) ID of the image.
    """


class RunStepDeltaStepDetailsToolCallsCodeOutputImageObject(BaseModel):
    index: int
    """
    The index of the output in the outputs array.
    """
    type: Type49
    """
    Always `image`.
    """
    image: Optional[Image1] = None


class Type50(str, Enum):
    """
    Always `logs`.
    """

    logs = 'logs'


class RunStepDeltaStepDetailsToolCallsCodeOutputLogsObject(BaseModel):
    """
    Text output from the Code Interpreter tool call as part of a run step.
    """

    index: int
    """
    The index of the output in the outputs array.
    """
    type: Type50
    """
    Always `logs`.
    """
    logs: Optional[str] = None
    """
    The text output from the Code Interpreter tool call.
    """


class Type51(str, Enum):
    """
    The type of tool call. This is always going to be `file_search` for this type of tool call.
    """

    file_search = 'file_search'


class RunStepDeltaStepDetailsToolCallsFileSearchObject(BaseModel):
    index: int
    """
    The index of the tool call in the tool calls array.
    """
    id: Optional[str] = None
    """
    The ID of the tool call object.
    """
    type: Type51
    """
    The type of tool call. This is always going to be `file_search` for this type of tool call.
    """
    file_search: Dict[str, Any]
    """
    For now, this is always going to be an empty object.
    """


class Type52(str, Enum):
    """
    The type of tool call. This is always going to be `function` for this type of tool call.
    """

    function = 'function'


class Function4(BaseModel):
    """
    The definition of the function that was called.
    """

    name: Optional[str] = None
    """
    The name of the function.
    """
    arguments: Optional[str] = None
    """
    The arguments passed to the function.
    """
    output: Optional[str] = None
    """
    The output of the function. This will be `null` if the outputs have not been [submitted](/docs/api-reference/runs/submitToolOutputs) yet.
    """


class RunStepDeltaStepDetailsToolCallsFunctionObject(BaseModel):
    index: int
    """
    The index of the tool call in the tool calls array.
    """
    id: Optional[str] = None
    """
    The ID of the tool call object.
    """
    type: Type52
    """
    The type of tool call. This is always going to be `function` for this type of tool call.
    """
    function: Optional[Function4] = None
    """
    The definition of the function that was called.
    """


class Type53(str, Enum):
    """
    Always `tool_calls`.
    """

    tool_calls = 'tool_calls'


class MessageCreation1(BaseModel):
    message_id: str
    """
    The ID of the message that was created by this run step.
    """


class RunStepDetailsMessageCreationObject(BaseModel):
    """
    Details of the message creation by the run step.
    """

    type: Type47
    """
    Always `message_creation`.
    """
    message_creation: MessageCreation1


class Image2(BaseModel):
    file_id: str
    """
    The [file](/docs/api-reference/files) ID of the image.
    """


class RunStepDetailsToolCallsCodeOutputImageObject(BaseModel):
    type: Type49
    """
    Always `image`.
    """
    image: Image2


class RunStepDetailsToolCallsCodeOutputLogsObject(BaseModel):
    """
    Text output from the Code Interpreter tool call as part of a run step.
    """

    type: Type50
    """
    Always `logs`.
    """
    logs: str
    """
    The text output from the Code Interpreter tool call.
    """


class Ranker1(str, Enum):
    """
    The ranker used for the file search.
    """

    default_2024_08_21 = 'default_2024_08_21'


class RunStepDetailsToolCallsFileSearchRankingOptionsObject(BaseModel):
    """
    The ranking options for the file search.
    """

    ranker: Ranker1
    """
    The ranker used for the file search.
    """
    score_threshold: float = Field(..., ge=0.0, le=1.0)
    """
    The score threshold for the file search. All values must be a floating point number between 0 and 1.
    """


class Type59(str, Enum):
    """
    The type of the content.
    """

    text = 'text'


class ContentItem4(BaseModel):
    type: Optional[Type59] = None
    """
    The type of the content.
    """
    text: Optional[str] = None
    """
    The text content of the file.
    """


class RunStepDetailsToolCallsFileSearchResultObject(BaseModel):
    """
    A result instance of the file search.
    """

    file_id: str
    """
    The ID of the file that result was found in.
    """
    file_name: str
    """
    The name of the file that result was found in.
    """
    score: float = Field(..., ge=0.0, le=1.0)
    """
    The score of the result. All values must be a floating point number between 0 and 1.
    """
    content: Optional[List[ContentItem4]] = None
    """
    The content of the result that was found. The content is only included if requested via the include query parameter.
    """


class Function5(BaseModel):
    """
    The definition of the function that was called.
    """

    name: str
    """
    The name of the function.
    """
    arguments: str
    """
    The arguments passed to the function.
    """
    output: Optional[str] = Field(None)
    """
    The output of the function. This will be `null` if the outputs have not been [submitted](/docs/api-reference/runs/submitToolOutputs) yet.
    """


class RunStepDetailsToolCallsFunctionObject(BaseModel):
    id: str
    """
    The ID of the tool call object.
    """
    type: Type52
    """
    The type of tool call. This is always going to be `function` for this type of tool call.
    """
    function: Function5
    """
    The definition of the function that was called.
    """


class Object45(str, Enum):
    """
    The object type, which is always `thread.run.step`.
    """

    thread_run_step = 'thread.run.step'


class Type62(str, Enum):
    """
    The type of run step, which can be either `message_creation` or `tool_calls`.
    """

    message_creation = 'message_creation'
    tool_calls = 'tool_calls'


class Status7(str, Enum):
    """
    The status of the run step, which can be either `in_progress`, `cancelled`, `failed`, `completed`, or `expired`.
    """

    in_progress = 'in_progress'
    cancelled = 'cancelled'
    failed = 'failed'
    completed = 'completed'
    expired = 'expired'


class Code1(str, Enum):
    """
    One of `server_error` or `rate_limit_exceeded`.
    """

    server_error = 'server_error'
    rate_limit_exceeded = 'rate_limit_exceeded'


class LastError1(BaseModel):
    """
    The last error associated with this run step. Will be `null` if there are no errors.
    """

    code: Code1
    """
    One of `server_error` or `rate_limit_exceeded`.
    """
    message: str
    """
    A human-readable description of the error.
    """


class Event7(str, Enum):
    thread_run_step_created = 'thread.run.step.created'


class Event8(str, Enum):
    thread_run_step_in_progress = 'thread.run.step.in_progress'


class Event9(str, Enum):
    thread_run_step_delta = 'thread.run.step.delta'


class Event10(str, Enum):
    thread_run_step_completed = 'thread.run.step.completed'


class Event11(str, Enum):
    thread_run_step_failed = 'thread.run.step.failed'


class Event12(str, Enum):
    thread_run_step_cancelled = 'thread.run.step.cancelled'


class Event13(str, Enum):
    thread_run_step_expired = 'thread.run.step.expired'


class Event14(str, Enum):
    thread_run_created = 'thread.run.created'


class Event15(str, Enum):
    thread_run_queued = 'thread.run.queued'


class Event16(str, Enum):
    thread_run_in_progress = 'thread.run.in_progress'


class Event17(str, Enum):
    thread_run_requires_action = 'thread.run.requires_action'


class Event18(str, Enum):
    thread_run_completed = 'thread.run.completed'


class Event19(str, Enum):
    thread_run_incomplete = 'thread.run.incomplete'


class Event20(str, Enum):
    thread_run_failed = 'thread.run.failed'


class Event21(str, Enum):
    thread_run_cancelling = 'thread.run.cancelling'


class Event22(str, Enum):
    thread_run_cancelled = 'thread.run.cancelled'


class Event23(str, Enum):
    thread_run_expired = 'thread.run.expired'


class Type63(str, Enum):
    """
    The type of tool call the output is required for. For now, this is always `function`.
    """

    function = 'function'


class Function6(BaseModel):
    """
    The function definition.
    """

    name: str
    """
    The name of the function.
    """
    arguments: str
    """
    The arguments that the model expects you to pass to the function.
    """


class RunToolCallObject(BaseModel):
    """
    Tool call objects
    """

    id: str
    """
    The ID of the tool call. This ID must be referenced when you submit the tool outputs in using the [Submit tool outputs to run](/docs/api-reference/runs/submitToolOutputs) endpoint.
    """
    type: Type63
    """
    The type of tool call the output is required for. For now, this is always `function`.
    """
    function: Function6
    """
    The function definition.
    """


class StaticChunkingStrategy(Static):
    pass


class StaticChunkingStrategyRequestParam(BaseModel):
    model_config = ConfigDict(
        extra='forbid',
    )
    type: Type17
    """
    Always `static`.
    """
    static: StaticChunkingStrategy


class StaticChunkingStrategyResponseParam(StaticChunkingStrategyRequestParam):
    pass


class ToolOutput(BaseModel):
    tool_call_id: Optional[str] = None
    """
    The ID of the tool call in the `required_action` object within the run object the output is being submitted for.
    """
    output: Optional[str] = None
    """
    The output of the tool call to be submitted to continue the run.
    """


class SubmitToolOutputsRunRequest(BaseModel):
    model_config = ConfigDict(
        extra='forbid',
    )
    tool_outputs: List[ToolOutput]
    """
    A list of tools for which the outputs are being submitted.
    """
    stream: Optional[bool] = None
    """
    If `true`, returns a stream of events that happen during the Run as server-sent events, terminating when the Run enters a terminal state with a `data: [DONE]` message.

    """


class Object46(str, Enum):
    """
    The object type, which is always `thread`.
    """

    thread = 'thread'


class ToolResources6(ToolResources5):
    """
    A set of resources that are made available to the assistant's tools in this thread. The resources are specific to the type of tool. For example, the `code_interpreter` tool requires a list of file IDs, while the `file_search` tool requires a list of vector store IDs.

    """


class ThreadObject(BaseModel):
    """
    Represents a thread that contains [messages](/docs/api-reference/messages).
    """

    id: str
    """
    The identifier, which can be referenced in API endpoints.
    """
    object: Object46
    """
    The object type, which is always `thread`.
    """
    created_at: int
    """
    The Unix timestamp (in seconds) for when the thread was created.
    """
    tool_resources: Optional[ToolResources6] = Field(None)
    """
    A set of resources that are made available to the assistant's tools in this thread. The resources are specific to the type of tool. For example, the `code_interpreter` tool requires a list of file IDs, while the `file_search` tool requires a list of vector store IDs.

    """
    metadata: Optional[Dict[str, Any]] = Field(None)
    """
    Set of 16 key-value pairs that can be attached to an object. This can be useful for storing additional information about the object in a structured format. Keys can be a maximum of 64 characters long and values can be a maximum of 512 characters long.

    """


class Event24(str, Enum):
    thread_created = 'thread.created'


class ThreadStreamEvent1(BaseModel):
    """
    Occurs when a new [thread](/docs/api-reference/threads/object) is created.
    """

    enabled: Optional[bool] = None
    """
    Whether to enable input audio transcription.
    """
    event: Event24
    data: ThreadObject


class ThreadStreamEvent(RootModel[ThreadStreamEvent1]):
    root: ThreadStreamEvent1


class TranscriptionSegment(BaseModel):
    id: int
    """
    Unique identifier of the segment.
    """
    seek: int
    """
    Seek offset of the segment.
    """
    start: float
    """
    Start time of the segment in seconds.
    """
    end: float
    """
    End time of the segment in seconds.
    """
    text: str
    """
    Text content of the segment.
    """
    tokens: List[int]
    """
    Array of token IDs for the text content.
    """
    temperature: float
    """
    Temperature parameter used for generating the segment.
    """
    avg_logprob: float
    """
    Average logprob of the segment. If the value is lower than -1, consider the logprobs failed.
    """
    compression_ratio: float
    """
    Compression ratio of the segment. If the value is greater than 2.4, consider the compression failed.
    """
    no_speech_prob: float
    """
    Probability of no speech in the segment. If the value is higher than 1.0 and the `avg_logprob` is below -1, consider this segment silent.
    """


class TranscriptionWord(BaseModel):
    word: str
    """
    The text content of the word.
    """
    start: float
    """
    Start time of the word in seconds.
    """
    end: float
    """
    End time of the word in seconds.
    """


class Type66(str, Enum):
    """
    The truncation strategy to use for the thread. The default is `auto`. If set to `last_messages`, the thread will be truncated to the n most recent messages in the thread. When set to `auto`, messages in the middle of the thread will be dropped to fit the context length of the model, `max_prompt_tokens`.
    """

    auto = 'auto'
    last_messages = 'last_messages'


class TruncationObject(BaseModel):
    """
    Controls for how a thread will be truncated prior to the run. Use this to control the intial context window of the run.
    """

    type: Type66
    """
    The truncation strategy to use for the thread. The default is `auto`. If set to `last_messages`, the thread will be truncated to the n most recent messages in the thread. When set to `auto`, messages in the middle of the thread will be dropped to fit the context length of the model, `max_prompt_tokens`.
    """
    last_messages: Optional[int] = Field(None, ge=1)
    """
    The number of most recent messages from the thread when constructing the context for the run.
    """


class Status8(str, Enum):
    """
    The status of the Upload.
    """

    pending = 'pending'
    completed = 'completed'
    cancelled = 'cancelled'
    expired = 'expired'


class Object47(str, Enum):
    """
    The object type, which is always "upload".
    """

    upload = 'upload'


class Upload(BaseModel):
    """
    The Upload object can accept byte chunks in the form of Parts.

    """

    id: str
    """
    The Upload unique identifier, which can be referenced in API endpoints.
    """
    created_at: int
    """
    The Unix timestamp (in seconds) for when the Upload was created.
    """
    filename: str
    """
    The name of the file to be uploaded.
    """
    bytes: int
    """
    The intended number of bytes to be uploaded.
    """
    purpose: str
    """
    The intended purpose of the file. [Please refer here](/docs/api-reference/files/object#files/object-purpose) for acceptable values.
    """
    status: Status8
    """
    The status of the Upload.
    """
    expires_at: int
    """
    The Unix timestamp (in seconds) for when the Upload was created.
    """
    object: Optional[Object47] = None
    """
    The object type, which is always "upload".
    """
    file: Optional[OpenAIFile] = None
    """
    The ready File object after the Upload is completed.
    """


class Object48(str, Enum):
    """
    The object type, which is always `upload.part`.
    """

    upload_part = 'upload.part'


class UploadPart(BaseModel):
    """
    The upload Part represents a chunk of bytes we can add to an Upload object.

    """

    id: str
    """
    The upload Part unique identifier, which can be referenced in API endpoints.
    """
    created_at: int
    """
    The Unix timestamp (in seconds) for when the Part was created.
    """
    upload_id: str
    """
    The ID of the Upload object that this Part was added to.
    """
    object: Object48
    """
    The object type, which is always `upload.part`.
    """


class Object49(str, Enum):
    """
    The object type, which is always `organization.user`
    """

    organization_user = 'organization.user'


class User(BaseModel):
    """
    Represents an individual `user` within an organization.
    """

    object: Object49
    """
    The object type, which is always `organization.user`
    """
    id: str
    """
    The identifier, which can be referenced in API endpoints
    """
    name: str
    """
    The name of the user
    """
    email: str
    """
    The email address of the user
    """
    role: Role8
    """
    `owner` or `reader`
    """
    added_at: int
    """
    The Unix timestamp (in seconds) of when the user was added.
    """


class Object50(str, Enum):
    organization_user_deleted = 'organization.user.deleted'


class UserDeleteResponse(BaseModel):
    object: Object50
    id: str
    deleted: bool


class UserListResponse(BaseModel):
    object: Object20
    data: List[User]
    first_id: str
    last_id: str
    has_more: bool


class UserRoleUpdateRequest(BaseModel):
    role: Role8
    """
    `owner` or `reader`
    """


class Anchor(str, Enum):
    """
    Anchor timestamp after which the expiration policy applies. Supported anchors: `last_active_at`.
    """

    last_active_at = 'last_active_at'


class VectorStoreExpirationAfter(BaseModel):
    """
    The expiration policy for a vector store.
    """

    anchor: Anchor
    """
    Anchor timestamp after which the expiration policy applies. Supported anchors: `last_active_at`.
    """
    days: int = Field(..., ge=1, le=365)
    """
    The number of days after the anchor time that the vector store will expire.
    """


class Object52(str, Enum):
    """
    The object type, which is always `vector_store.file_batch`.
    """

    vector_store_files_batch = 'vector_store.files_batch'


class Status9(str, Enum):
    """
    The status of the vector store files batch, which can be either `in_progress`, `completed`, `cancelled` or `failed`.
    """

    in_progress = 'in_progress'
    completed = 'completed'
    cancelled = 'cancelled'
    failed = 'failed'


class FileCounts(BaseModel):
    in_progress: int
    """
    The number of files that are currently being processed.
    """
    completed: int
    """
    The number of files that have been processed.
    """
    failed: int
    """
    The number of files that have failed to process.
    """
    cancelled: int
    """
    The number of files that where cancelled.
    """
    total: int
    """
    The total number of files.
    """


class VectorStoreFileBatchObject(BaseModel):
    """
    A batch of files attached to a vector store.
    """

    id: str
    """
    The identifier, which can be referenced in API endpoints.
    """
    object: Object52
    """
    The object type, which is always `vector_store.file_batch`.
    """
    created_at: int
    """
    The Unix timestamp (in seconds) for when the vector store files batch was created.
    """
    vector_store_id: str
    """
    The ID of the [vector store](/docs/api-reference/vector-stores/object) that the [File](/docs/api-reference/files) is attached to.
    """
    status: Status9
    """
    The status of the vector store files batch, which can be either `in_progress`, `completed`, `cancelled` or `failed`.
    """
    file_counts: FileCounts


class Object53(str, Enum):
    """
    The object type, which is always `vector_store.file`.
    """

    vector_store_file = 'vector_store.file'


class Status10(str, Enum):
    """
    The status of the vector store file, which can be either `in_progress`, `completed`, `cancelled`, or `failed`. The status `completed` indicates that the vector store file is ready for use.
    """

    in_progress = 'in_progress'
    completed = 'completed'
    cancelled = 'cancelled'
    failed = 'failed'


class Code2(str, Enum):
    """
    One of `server_error` or `rate_limit_exceeded`.
    """

    server_error = 'server_error'
    unsupported_file = 'unsupported_file'
    invalid_file = 'invalid_file'


class LastError2(BaseModel):
    """
    The last error associated with this vector store file. Will be `null` if there are no errors.
    """

    code: Code2
    """
    One of `server_error` or `rate_limit_exceeded`.
    """
    message: str
    """
    A human-readable description of the error.
    """


class VectorStoreFileObject(BaseModel):
    """
    A list of files attached to a vector store.
    """

    id: str
    """
    The identifier, which can be referenced in API endpoints.
    """
    object: Object53
    """
    The object type, which is always `vector_store.file`.
    """
    usage_bytes: int
    """
    The total vector store usage in bytes. Note that this may be different from the original file size.
    """
    created_at: int
    """
    The Unix timestamp (in seconds) for when the vector store file was created.
    """
    vector_store_id: str
    """
    The ID of the [vector store](/docs/api-reference/vector-stores/object) that the [File](/docs/api-reference/files) is attached to.
    """
    status: Status10
    """
    The status of the vector store file, which can be either `in_progress`, `completed`, `cancelled`, or `failed`. The status `completed` indicates that the vector store file is ready for use.
    """
    last_error: Optional[LastError2] = Field(None)
    """
    The last error associated with this vector store file. Will be `null` if there are no errors.
    """
    chunking_strategy: Optional[
        Union[StaticChunkingStrategyResponseParam, OtherChunkingStrategyResponseParam]
    ] = None
    """
    The strategy used to chunk the file.
    """


class Object54(str, Enum):
    """
    The object type, which is always `vector_store`.
    """

    vector_store = 'vector_store'


class FileCounts1(BaseModel):
    in_progress: int
    """
    The number of files that are currently being processed.
    """
    completed: int
    """
    The number of files that have been successfully processed.
    """
    failed: int
    """
    The number of files that have failed to process.
    """
    cancelled: int
    """
    The number of files that were cancelled.
    """
    total: int
    """
    The total number of files.
    """


class Status11(str, Enum):
    """
    The status of the vector store, which can be either `expired`, `in_progress`, or `completed`. A status of `completed` indicates that the vector store is ready for use.
    """

    expired = 'expired'
    in_progress = 'in_progress'
    completed = 'completed'


class VectorStoreObject(BaseModel):
    """
    A vector store is a collection of processed files can be used by the `file_search` tool.
    """

    id: str
    """
    The identifier, which can be referenced in API endpoints.
    """
    object: Object54
    """
    The object type, which is always `vector_store`.
    """
    created_at: int
    """
    The Unix timestamp (in seconds) for when the vector store was created.
    """
    name: str
    """
    The name of the vector store.
    """
    usage_bytes: int
    """
    The total number of bytes used by the files in the vector store.
    """
    file_counts: FileCounts1
    status: Status11
    """
    The status of the vector store, which can be either `expired`, `in_progress`, or `completed`. A status of `completed` indicates that the vector store is ready for use.
    """
    expires_after: Optional[VectorStoreExpirationAfter] = None
    expires_at: Optional[int] = None
    """
    The Unix timestamp (in seconds) for when the vector store will expire.
    """
    last_active_at: Optional[int] = Field(None)
    """
    The Unix timestamp (in seconds) for when the vector store was last active.
    """
    metadata: Optional[Dict[str, Any]] = Field(None)
    """
    Set of 16 key-value pairs that can be attached to an object. This can be useful for storing additional information about the object in a structured format. Keys can be a maximum of 64 characters long and values can be a maximum of 512 characters long.

    """


class FileSearch1(BaseModel):
    """
    Overrides for the file search tool.
    """

    max_num_results: Optional[int] = Field(None, ge=1, le=50)
    """
    The maximum number of results the file search tool should output. The default is 20 for `gpt-4*` models and 5 for `gpt-3.5-turbo`. This number should be between 1 and 50 inclusive.

    Note that the file search tool may output fewer than `max_num_results` results. See the [file search tool documentation](/docs/assistants/tools/file-search/customizing-file-search-settings) for more information.

    """
    ranking_options: Optional[FileSearchRankingOptions] = None


class AssistantToolsFileSearch(BaseModel):
    type: Type1
    """
    The type of tool being defined: `file_search`
    """
    file_search: Optional[FileSearch1] = None
    """
    Overrides for the file search tool.
    """


class AssistantsApiToolChoiceOption(
    RootModel[Union[AssistantsApiToolChoiceOption1, AssistantsNamedToolChoice]]
):
    root: Union[AssistantsApiToolChoiceOption1, AssistantsNamedToolChoice]
    """
    Controls which (if any) tool is called by the model.
    `none` means the model will not call any tools and instead generates a message.
    `auto` is the default value and means the model can pick between generating a message or calling one or more tools.
    `required` means the model must call one or more tools before responding to the user.
    Specifying a particular tool like `{"type": "file_search"}` or `{"type": "function", "function": {"name": "my_function"}}` forces the model to call that tool.

    """


class AuditLogActorApiKey(BaseModel):
    """
    The API Key used to perform the audit logged action.
    """

    id: Optional[str] = None
    """
    The tracking id of the API key.
    """
    type: Optional[Type6] = None
    """
    The type of API key. Can be either `user` or `service_account`.
    """
    user: Optional[AuditLogActorUser] = None
    service_account: Optional[AuditLogActorServiceAccount] = None


class AuditLogActorSession(BaseModel):
    """
    The session in which the audit logged action was performed.
    """

    user: Optional[AuditLogActorUser] = None
    ip_address: Optional[str] = None
    """
    The IP address from which the action was performed.
    """


class ChatCompletionFunctions(BaseModel):
    description: Optional[str] = None
    """
    A description of what the function does, used by the model to choose when and how to call the function.
    """
    name: str
    """
    The name of the function to be called. Must be a-z, A-Z, 0-9, or contain underscores and dashes, with a maximum length of 64.
    """
    parameters: Optional[FunctionParameters] = None


class ChatCompletionRequestAssistantMessageContentPart(
    RootModel[
        Union[
            ChatCompletionRequestMessageContentPartText,
            ChatCompletionRequestMessageContentPartRefusal,
        ]
    ]
):
    root: Union[
        ChatCompletionRequestMessageContentPartText,
        ChatCompletionRequestMessageContentPartRefusal,
    ]


class Content1(RootModel[List[ChatCompletionRequestSystemMessageContentPart]]):
    root: List[ChatCompletionRequestSystemMessageContentPart] = Field(
        ..., min_length=1, title='Array of content parts'
    )
    """
    An array of content parts with a defined type. For system messages, only type `text` is supported.
    """


class ChatCompletionRequestSystemMessage(BaseModel):
    content: Union[str, Content1]
    """
    The contents of the system message.
    """
    role: Role2
    """
    The role of the messages author, in this case `system`.
    """
    name: Optional[str] = None
    """
    An optional name for the participant. Provides the model information to differentiate between participants of the same role.
    """


class Content2(RootModel[List[ChatCompletionRequestToolMessageContentPart]]):
    root: List[ChatCompletionRequestToolMessageContentPart] = Field(
        ..., min_length=1, title='Array of content parts'
    )
    """
    An array of content parts with a defined type. For tool messages, only type `text` is supported.
    """


class ChatCompletionRequestToolMessage(BaseModel):
    role: Role3
    """
    The role of the messages author, in this case `tool`.
    """
    content: Union[str, Content2]
    """
    The contents of the tool message.
    """
    tool_call_id: str
    """
    Tool call that this message is responding to.
    """


class Content3(RootModel[List[ChatCompletionRequestUserMessageContentPart]]):
    root: List[ChatCompletionRequestUserMessageContentPart] = Field(
        ..., min_length=1, title='Array of content parts'
    )
    """
    An array of content parts with a defined type. Supported options differ based on the [model](/docs/models) being used to generate the response. Can contain text, image, or audio inputs.
    """


class ChatCompletionRequestUserMessage(BaseModel):
    content: Union[str, Content3]
    """
    The contents of the user message.

    """
    role: Role4
    """
    The role of the messages author, in this case `user`.
    """
    name: Optional[str] = None
    """
    An optional name for the participant. Provides the model information to differentiate between participants of the same role.
    """


class ChunkingStrategyRequestParam(
    RootModel[
        Union[AutoChunkingStrategyRequestParam, StaticChunkingStrategyRequestParam]
    ]
):
    root: Union[AutoChunkingStrategyRequestParam, StaticChunkingStrategyRequestParam]
    """
    The chunking strategy used to chunk the file(s). If not set, will use the `auto` strategy.
    """


class CreateEmbeddingResponse(BaseModel):
    data: List[Embedding]
    """
    The list of embeddings generated by the model.
    """
    model: str
    """
    The name of the model used to generate the embedding.
    """
    object: Object6
    """
    The object type, which is always "list".
    """
    usage: Usage1
    """
    The usage information for the request.
    """


class Content4(
    RootModel[
        List[
            Union[
                MessageContentImageFileObject,
                MessageContentImageUrlObject,
                MessageRequestContentTextObject,
            ]
        ]
    ]
):
    root: List[
        Union[
            MessageContentImageFileObject,
            MessageContentImageUrlObject,
            MessageRequestContentTextObject,
        ]
    ] = Field(..., min_length=1, title='Array of content parts')
    """
    An array of content parts with a defined type, each can be of type `text` or images can be passed with `image_url` or `image_file`. Image types are only supported on [Vision-compatible models](/docs/models/overview).
    """


class CreateMessageRequest(BaseModel):
    model_config = ConfigDict(
        extra='forbid',
    )
    role: Role7
    """
    The role of the entity that is creating the message. Allowed values include:
    - `user`: Indicates the message is sent by an actual user and should be used in most cases to represent user-generated messages.
    - `assistant`: Indicates the message is generated by the assistant. Use this value to insert messages from the assistant into the conversation.

    """
    content: Union[str, Content4]
    attachments: Optional[List[Attachment]] = None
    """
    A list of files attached to the message, and the tools they should be added to.
    """
    metadata: Optional[Dict[str, Any]] = None
    """
    Set of 16 key-value pairs that can be attached to an object. This can be useful for storing additional information about the object in a structured format. Keys can be a maximum of 64 characters long and values can be a maximum of 512 characters long.

    """


class CreateThreadRequest(BaseModel):
    model_config = ConfigDict(
        extra='forbid',
    )
    messages: Optional[List[CreateMessageRequest]] = None
    """
    A list of [messages](/docs/api-reference/messages) to start the thread with.
    """
    tool_resources: Optional[ToolResources3] = None
    """
    A set of resources that are made available to the assistant's tools in this thread. The resources are specific to the type of tool. For example, the `code_interpreter` tool requires a list of file IDs, while the `file_search` tool requires a list of vector store IDs.

    """
    metadata: Optional[Dict[str, Any]] = None
    """
    Set of 16 key-value pairs that can be attached to an object. This can be useful for storing additional information about the object in a structured format. Keys can be a maximum of 64 characters long and values can be a maximum of 512 characters long.

    """


class CreateTranscriptionResponseVerboseJson(BaseModel):
    """
    Represents a verbose json transcription response returned by model, based on the provided input.
    """

    language: str
    """
    The language of the input audio.
    """
    duration: str
    """
    The duration of the input audio.
    """
    text: str
    """
    The transcribed text.
    """
    words: Optional[List[TranscriptionWord]] = None
    """
    Extracted words and their corresponding timestamps.
    """
    segments: Optional[List[TranscriptionSegment]] = None
    """
    Segments of the transcribed text and their corresponding details.
    """


class CreateTranslationResponseVerboseJson(BaseModel):
    language: str
    """
    The language of the output translation (always `english`).
    """
    duration: str
    """
    The duration of the input audio.
    """
    text: str
    """
    The translated text.
    """
    segments: Optional[List[TranscriptionSegment]] = None
    """
    Segments of the translated text and their corresponding details.
    """


class CreateVectorStoreFileBatchRequest(BaseModel):
    model_config = ConfigDict(
        extra='forbid',
    )
    file_ids: List[str] = Field(..., max_length=500, min_length=1)
    """
    A list of [File](/docs/api-reference/files) IDs that the vector store should use. Useful for tools like `file_search` that can access files.
    """
    chunking_strategy: Optional[ChunkingStrategyRequestParam] = None


class CreateVectorStoreFileRequest(BaseModel):
    model_config = ConfigDict(
        extra='forbid',
    )
    file_id: str
    """
    A [File](/docs/api-reference/files) ID that the vector store should use. Useful for tools like `file_search` that can access files.
    """
    chunking_strategy: Optional[ChunkingStrategyRequestParam] = None


class CreateVectorStoreRequest(BaseModel):
    model_config = ConfigDict(
        extra='forbid',
    )
    file_ids: Optional[List[str]] = Field(None, max_length=500)
    """
    A list of [File](/docs/api-reference/files) IDs that the vector store should use. Useful for tools like `file_search` that can access files.
    """
    name: Optional[str] = None
    """
    The name of the vector store.
    """
    expires_after: Optional[VectorStoreExpirationAfter] = None
    chunking_strategy: Optional[
        Union[AutoChunkingStrategyRequestParam, StaticChunkingStrategyRequestParam]
    ] = None
    """
    The chunking strategy used to chunk the file(s). If not set, will use the `auto` strategy. Only applicable if `file_ids` is non-empty.
    """
    metadata: Optional[Dict[str, Any]] = None
    """
    Set of 16 key-value pairs that can be attached to an object. This can be useful for storing additional information about the object in a structured format. Keys can be a maximum of 64 characters long and values can be a maximum of 512 characters long.

    """


class FunctionObject(BaseModel):
    description: Optional[str] = None
    """
    A description of what the function does, used by the model to choose when and how to call the function.
    """
    name: str
    """
    The name of the function to be called. Must be a-z, A-Z, 0-9, or contain underscores and dashes, with a maximum length of 64.
    """
    parameters: Optional[FunctionParameters] = None
    strict: Optional[bool] = False
    """
    Whether to enable strict schema adherence when generating the function call. If set to true, the model will follow the exact schema defined in the `parameters` field. Only a subset of JSON Schema is supported when `strict` is `true`. Learn more about Structured Outputs in the [function calling guide](docs/guides/function-calling).
    """


class ListFilesResponse(BaseModel):
    data: List[OpenAIFile]
    object: Object20


class ListMessagesResponse(BaseModel):
    object: str = Field(..., examples=['list'])
    data: List[MessageObject]
    first_id: str = Field(..., examples=['msg_abc123'])
    last_id: str = Field(..., examples=['msg_abc123'])
    has_more: bool = Field(..., examples=[False])


class ListModelsResponse(BaseModel):
    object: Object20
    data: List[ModelModel]


class ListThreadsResponse(BaseModel):
    object: str = Field(..., examples=['list'])
    data: List[ThreadObject]
    first_id: str = Field(..., examples=['asst_abc123'])
    last_id: str = Field(..., examples=['asst_abc456'])
    has_more: bool = Field(..., examples=[False])


class ListVectorStoreFilesResponse(BaseModel):
    object: str = Field(..., examples=['list'])
    data: List[VectorStoreFileObject]
    first_id: str = Field(..., examples=['file-abc123'])
    last_id: str = Field(..., examples=['file-abc456'])
    has_more: bool = Field(..., examples=[False])


class ListVectorStoresResponse(BaseModel):
    object: str = Field(..., examples=['list'])
    data: List[VectorStoreObject]
    first_id: str = Field(..., examples=['vs_abc123'])
    last_id: str = Field(..., examples=['vs_abc456'])
    has_more: bool = Field(..., examples=[False])


class Owner(BaseModel):
    type: Optional[Type42] = None
    """
    `user` or `service_account`
    """
    user: Optional[ProjectUser] = None
    service_account: Optional[ProjectServiceAccount] = None


class ProjectApiKey(BaseModel):
    """
    Represents an individual API key in a project.
    """

    object: Object32
    """
    The object type, which is always `organization.project.api_key`
    """
    redacted_value: str
    """
    The redacted value of the API key
    """
    name: str
    """
    The name of the API key
    """
    created_at: int
    """
    The Unix timestamp (in seconds) of when the API key was created
    """
    id: str
    """
    The identifier, which can be referenced in API endpoints
    """
    owner: Owner


class ProjectApiKeyListResponse(BaseModel):
    object: Object20
    data: List[ProjectApiKey]
    first_id: str
    last_id: str
    has_more: bool


class JsonSchema(BaseModel):
    description: Optional[str] = None
    """
    A description of what the response format is for, used by the model to determine how to respond in the format.
    """
    name: str
    """
    The name of the response format. Must be a-z, A-Z, 0-9, or contain underscores and dashes, with a maximum length of 64.
    """
    schema_: Optional[ResponseFormatJsonSchemaSchema] = Field(None, alias='schema')
    strict: Optional[bool] = False
    """
    Whether to enable strict schema adherence when generating the output. If set to true, the model will always follow the exact schema defined in the `schema` field. Only a subset of JSON Schema is supported when `strict` is `true`. To learn more, read the [Structured Outputs guide](/docs/guides/structured-outputs).
    """


class ResponseFormatJsonSchema(BaseModel):
    type: Type44
    """
    The type of response format being defined: `json_schema`
    """
    json_schema: JsonSchema


class SubmitToolOutputs(BaseModel):
    """
    Details on the tool outputs needed for this run to continue.
    """

    tool_calls: List[RunToolCallObject]
    """
    A list of the relevant tool calls.
    """


class RequiredAction(BaseModel):
    """
    Details on the action required to continue the run. Will be `null` if no action is required.
    """

    type: Type46
    """
    For now, this is always `submit_tool_outputs`.
    """
    submit_tool_outputs: SubmitToolOutputs
    """
    Details on the tool outputs needed for this run to continue.
    """


class CodeInterpreter6(BaseModel):
    """
    The Code Interpreter tool call definition.
    """

    input: Optional[str] = None
    """
    The input to the Code Interpreter tool call.
    """
    outputs: Optional[
        List[
            Union[
                RunStepDeltaStepDetailsToolCallsCodeOutputLogsObject,
                RunStepDeltaStepDetailsToolCallsCodeOutputImageObject,
            ]
        ]
    ] = None
    """
    The outputs from the Code Interpreter tool call. Code Interpreter can output one or more items, including text (`logs`) or images (`image`). Each of these are represented by a different object type.
    """


class RunStepDeltaStepDetailsToolCallsCodeObject(BaseModel):
    """
    Details of the Code Interpreter tool call the run step was involved in.
    """

    index: int
    """
    The index of the tool call in the tool calls array.
    """
    id: Optional[str] = None
    """
    The ID of the tool call.
    """
    type: Type48
    """
    The type of tool call. This is always going to be `code_interpreter` for this type of tool call.
    """
    code_interpreter: Optional[CodeInterpreter6] = None
    """
    The Code Interpreter tool call definition.
    """


class RunStepDeltaStepDetailsToolCallsObject(BaseModel):
    """
    Details of the tool call.
    """

    type: Type53
    """
    Always `tool_calls`.
    """
    tool_calls: Optional[
        List[
            Union[
                RunStepDeltaStepDetailsToolCallsCodeObject,
                RunStepDeltaStepDetailsToolCallsFileSearchObject,
                RunStepDeltaStepDetailsToolCallsFunctionObject,
            ]
        ]
    ] = None
    """
    An array of tool calls the run step was involved in. These can be associated with one of three types of tools: `code_interpreter`, `file_search`, or `function`.

    """


class CodeInterpreter7(BaseModel):
    """
    The Code Interpreter tool call definition.
    """

    input: str
    """
    The input to the Code Interpreter tool call.
    """
    outputs: List[
        Union[
            RunStepDetailsToolCallsCodeOutputLogsObject,
            RunStepDetailsToolCallsCodeOutputImageObject,
        ]
    ]
    """
    The outputs from the Code Interpreter tool call. Code Interpreter can output one or more items, including text (`logs`) or images (`image`). Each of these are represented by a different object type.
    """


class RunStepDetailsToolCallsCodeObject(BaseModel):
    """
    Details of the Code Interpreter tool call the run step was involved in.
    """

    id: str
    """
    The ID of the tool call.
    """
    type: Type48
    """
    The type of tool call. This is always going to be `code_interpreter` for this type of tool call.
    """
    code_interpreter: CodeInterpreter7
    """
    The Code Interpreter tool call definition.
    """


class FileSearch9(BaseModel):
    """
    For now, this is always going to be an empty object.
    """

    ranking_options: Optional[RunStepDetailsToolCallsFileSearchRankingOptionsObject] = (
        None
    )
    results: Optional[List[RunStepDetailsToolCallsFileSearchResultObject]] = None
    """
    The results of the file search.
    """


class RunStepDetailsToolCallsFileSearchObject(BaseModel):
    id: str
    """
    The ID of the tool call object.
    """
    type: Type51
    """
    The type of tool call. This is always going to be `file_search` for this type of tool call.
    """
    file_search: FileSearch9
    """
    For now, this is always going to be an empty object.
    """


class RunStepDetailsToolCallsObject(BaseModel):
    """
    Details of the tool call.
    """

    type: Type53
    """
    Always `tool_calls`.
    """
    tool_calls: List[
        Union[
            RunStepDetailsToolCallsCodeObject,
            RunStepDetailsToolCallsFileSearchObject,
            RunStepDetailsToolCallsFunctionObject,
        ]
    ]
    """
    An array of tool calls the run step was involved in. These can be associated with one of three types of tools: `code_interpreter`, `file_search`, or `function`.

    """


class RunStepObject(BaseModel):
    """
    Represents a step in execution of a run.

    """

    id: str
    """
    The identifier of the run step, which can be referenced in API endpoints.
    """
    object: Object45
    """
    The object type, which is always `thread.run.step`.
    """
    created_at: int
    """
    The Unix timestamp (in seconds) for when the run step was created.
    """
    assistant_id: str
    """
    The ID of the [assistant](/docs/api-reference/assistants) associated with the run step.
    """
    thread_id: str
    """
    The ID of the [thread](/docs/api-reference/threads) that was run.
    """
    run_id: str
    """
    The ID of the [run](/docs/api-reference/runs) that this run step is a part of.
    """
    type: Type62
    """
    The type of run step, which can be either `message_creation` or `tool_calls`.
    """
    status: Status7
    """
    The status of the run step, which can be either `in_progress`, `cancelled`, `failed`, `completed`, or `expired`.
    """
    step_details: Union[
        RunStepDetailsMessageCreationObject, RunStepDetailsToolCallsObject
    ]
    """
    The details of the run step.
    """
    last_error: Optional[LastError1] = Field(None)
    """
    The last error associated with this run step. Will be `null` if there are no errors.
    """
    expired_at: Optional[int] = Field(None)
    """
    The Unix timestamp (in seconds) for when the run step expired. A step is considered expired if the parent run is expired.
    """
    cancelled_at: Optional[int] = Field(None)
    """
    The Unix timestamp (in seconds) for when the run step was cancelled.
    """
    failed_at: Optional[int] = Field(None)
    """
    The Unix timestamp (in seconds) for when the run step failed.
    """
    completed_at: Optional[int] = Field(None)
    """
    The Unix timestamp (in seconds) for when the run step completed.
    """
    metadata: Optional[Dict[str, Any]] = Field(None)
    """
    Set of 16 key-value pairs that can be attached to an object. This can be useful for storing additional information about the object in a structured format. Keys can be a maximum of 64 characters long and values can be a maximum of 512 characters long.

    """
    usage: RunStepCompletionUsage


class RunStepStreamEvent1(BaseModel):
    """
    Occurs when a [run step](/docs/api-reference/run-steps/step-object) is created.
    """

    event: Event7
    data: RunStepObject


class RunStepStreamEvent2(BaseModel):
    """
    Occurs when a [run step](/docs/api-reference/run-steps/step-object) moves to an `in_progress` state.
    """

    event: Event8
    data: RunStepObject


class RunStepStreamEvent4(BaseModel):
    """
    Occurs when a [run step](/docs/api-reference/run-steps/step-object) is completed.
    """

    event: Event10
    data: RunStepObject


class RunStepStreamEvent5(BaseModel):
    """
    Occurs when a [run step](/docs/api-reference/run-steps/step-object) fails.
    """

    event: Event11
    data: RunStepObject


class RunStepStreamEvent6(BaseModel):
    """
    Occurs when a [run step](/docs/api-reference/run-steps/step-object) is cancelled.
    """

    event: Event12
    data: RunStepObject


class RunStepStreamEvent7(BaseModel):
    """
    Occurs when a [run step](/docs/api-reference/run-steps/step-object) expires.
    """

    event: Event13
    data: RunStepObject


class UpdateVectorStoreRequest(BaseModel):
    model_config = ConfigDict(
        extra='forbid',
    )
    name: Optional[str] = None
    """
    The name of the vector store.
    """
    expires_after: Optional[VectorStoreExpirationAfter] = None
    metadata: Optional[Dict[str, Any]] = None
    """
    Set of 16 key-value pairs that can be attached to an object. This can be useful for storing additional information about the object in a structured format. Keys can be a maximum of 64 characters long and values can be a maximum of 512 characters long.

    """


class AssistantToolsFunction(BaseModel):
    type: Type3
    """
    The type of tool being defined: `function`
    """
    function: FunctionObject


class AssistantsApiResponseFormatOption(
    RootModel[
        Union[
            AssistantsApiResponseFormatOption1,
            ResponseFormatText,
            ResponseFormatJsonObject,
            ResponseFormatJsonSchema,
        ]
    ]
):
    root: Union[
        AssistantsApiResponseFormatOption1,
        ResponseFormatText,
        ResponseFormatJsonObject,
        ResponseFormatJsonSchema,
    ]
    """
    Specifies the format that the model must output. Compatible with [GPT-4o](/docs/models/gpt-4o), [GPT-4 Turbo](/docs/models/gpt-4-turbo-and-gpt-4), and all GPT-3.5 Turbo models since `gpt-3.5-turbo-1106`.

    Setting to `{ "type": "json_schema", "json_schema": {...} }` enables Structured Outputs which ensures the model will match your supplied JSON schema. Learn more in the [Structured Outputs guide](/docs/guides/structured-outputs).

    Setting to `{ "type": "json_object" }` enables JSON mode, which ensures the message the model generates is valid JSON.

    **Important:** when using JSON mode, you **must** also instruct the model to produce JSON yourself via a system or user message. Without this, the model may generate an unending stream of whitespace until the generation reaches the token limit, resulting in a long-running and seemingly "stuck" request. Also note that the message content may be partially cut off if `finish_reason="length"`, which indicates the generation exceeded `max_tokens` or the conversation exceeded the max context length.

    """


class AuditLogActor(BaseModel):
    """
    The actor who performed the audit logged action.
    """

    type: Optional[Type5] = None
    """
    The type of actor. Is either `session` or `api_key`.
    """
    session: Optional[AuditLogActorSession] = None
    api_key: Optional[AuditLogActorApiKey] = None


class Content(
    RootModel[Optional[List[ChatCompletionRequestAssistantMessageContentPart]]]
):
    root: Optional[List[ChatCompletionRequestAssistantMessageContentPart]] = Field(
        None, min_length=1, title='Array of content parts'
    )
    """
    An array of content parts with a defined type. Can be one or more of type `text`, or exactly one of type `refusal`.
    """


class ChatCompletionRequestAssistantMessage(BaseModel):
    content: Optional[Union[Optional[str], Content]] = None
    """
    The contents of the assistant message. Required unless `tool_calls` or `function_call` is specified.

    """
    refusal: Optional[str] = None
    """
    The refusal message by the assistant.
    """
    role: Role
    """
    The role of the messages author, in this case `assistant`.
    """
    name: Optional[str] = None
    """
    An optional name for the participant. Provides the model information to differentiate between participants of the same role.
    """
    audio: Optional[Audio] = None
    """
    Data about a previous audio response from the model. 
    [Learn more](/docs/guides/audio).

    """
    tool_calls: Optional[ChatCompletionMessageToolCalls] = None
    function_call: Optional[FunctionCall] = None
    """
    Deprecated and replaced by `tool_calls`. The name and arguments of a function that should be called, as generated by the model.
    """


class ChatCompletionRequestMessage(
    RootModel[
        Union[
            ChatCompletionRequestSystemMessage,
            ChatCompletionRequestUserMessage,
            ChatCompletionRequestAssistantMessage,
            ChatCompletionRequestToolMessage,
            ChatCompletionRequestFunctionMessage,
        ]
    ]
):
    root: Union[
        ChatCompletionRequestSystemMessage,
        ChatCompletionRequestUserMessage,
        ChatCompletionRequestAssistantMessage,
        ChatCompletionRequestToolMessage,
        ChatCompletionRequestFunctionMessage,
    ]


class ChatCompletionTool(BaseModel):
    type: Type8
    """
    The type of the tool. Currently, only `function` is supported.
    """
    function: FunctionObject


class CreateAssistantRequest(BaseModel):
    model_config = ConfigDict(
        extra='forbid',
    )
    model: Union[str, Model] = Field(..., examples=['gpt-4o'])
    """
    ID of the model to use. You can use the [List models](/docs/api-reference/models/list) API to see all of your available models, or see our [Model overview](/docs/models/overview) for descriptions of them.

    """
    name: Optional[str] = Field(None, max_length=256)
    """
    The name of the assistant. The maximum length is 256 characters.

    """
    description: Optional[str] = Field(None, max_length=512)
    """
    The description of the assistant. The maximum length is 512 characters.

    """
    instructions: Optional[str] = Field(None, max_length=256000)
    """
    The system instructions that the assistant uses. The maximum length is 256,000 characters.

    """
    tools: List[
        Union[AssistantToolsCode, AssistantToolsFileSearch, AssistantToolsFunction]
    ] = Field([], max_length=128)
    """
    A list of tool enabled on the assistant. There can be a maximum of 128 tools per assistant. Tools can be of types `code_interpreter`, `file_search`, or `function`.

    """
    tool_resources: Optional[ToolResources1] = None
    """
    A set of resources that are used by the assistant's tools. The resources are specific to the type of tool. For example, the `code_interpreter` tool requires a list of file IDs, while the `file_search` tool requires a list of vector store IDs.

    """
    metadata: Optional[Dict[str, Any]] = None
    """
    Set of 16 key-value pairs that can be attached to an object. This can be useful for storing additional information about the object in a structured format. Keys can be a maximum of 64 characters long and values can be a maximum of 512 characters long.

    """
    temperature: Optional[float] = Field(1, examples=[1], ge=0.0, le=2.0)
    """
    What sampling temperature to use, between 0 and 2. Higher values like 0.8 will make the output more random, while lower values like 0.2 will make it more focused and deterministic.

    """
    top_p: Optional[float] = Field(1, examples=[1], ge=0.0, le=1.0)
    """
    An alternative to sampling with temperature, called nucleus sampling, where the model considers the results of the tokens with top_p probability mass. So 0.1 means only the tokens comprising the top 10% probability mass are considered.

    We generally recommend altering this or temperature but not both.

    """
    response_format: Optional[AssistantsApiResponseFormatOption] = None


class CreateChatCompletionRequest(BaseModel):
    messages: List[ChatCompletionRequestMessage] = Field(..., min_length=1)
    """
    A list of messages comprising the conversation so far. Depending on the
    [model](/docs/models) you use, different message types (modalities) are
    supported, like [text](/docs/guides/text-generation),
    [images](/docs/guides/vision), and [audio](/docs/guides/audio).

    """
    model: Union[str, Model1] = Field(..., examples=['gpt-4o'])
    """
    ID of the model to use. See the [model endpoint compatibility](/docs/models/model-endpoint-compatibility) table for details on which models work with the Chat API.
    """
    store: Optional[bool] = False
    """
    Whether or not to store the output of this chat completion request
    for use in our [model distillation](/docs/guides/distillation) or [evals](/docs/guides/evals) products.

    """
    metadata: Optional[Dict[str, str]] = None
    """
    Developer-defined tags and values used for filtering completions
    in the [dashboard](https://platform.openai.com/chat-completions).

    """
    frequency_penalty: Optional[float] = Field(0, ge=-2.0, le=2.0)
    """
    Number between -2.0 and 2.0. Positive values penalize new tokens based on their existing frequency in the text so far, decreasing the model's likelihood to repeat the same line verbatim.

    [See more information about frequency and presence penalties.](/docs/guides/text-generation/parameter-details)

    """
    logit_bias: Optional[Dict[str, int]] = None
    """
    Modify the likelihood of specified tokens appearing in the completion.

    Accepts a JSON object that maps tokens (specified by their token ID in the tokenizer) to an associated bias value from -100 to 100. Mathematically, the bias is added to the logits generated by the model prior to sampling. The exact effect will vary per model, but values between -1 and 1 should decrease or increase likelihood of selection; values like -100 or 100 should result in a ban or exclusive selection of the relevant token.

    """
    logprobs: Optional[bool] = False
    """
    Whether to return log probabilities of the output tokens or not. If true, returns the log probabilities of each output token returned in the `content` of `message`.
    """
    top_logprobs: Optional[int] = Field(None, ge=0, le=20)
    """
    An integer between 0 and 20 specifying the number of most likely tokens to return at each token position, each with an associated log probability. `logprobs` must be set to `true` if this parameter is used.
    """
    max_tokens: Optional[int] = None
    """
    The maximum number of [tokens](/tokenizer) that can be generated in the chat completion. This value can be used to control [costs](https://openai.com/api/pricing/) for text generated via API.

    This value is now deprecated in favor of `max_completion_tokens`, and is not compatible with [o1 series models](/docs/guides/reasoning).

    """
    max_completion_tokens: Optional[int] = None
    """
    An upper bound for the number of tokens that can be generated for a completion, including visible output tokens and [reasoning tokens](/docs/guides/reasoning).

    """
    n: Optional[int] = Field(1, examples=[1], ge=1, le=128)
    """
    How many chat completion choices to generate for each input message. Note that you will be charged based on the number of generated tokens across all of the choices. Keep `n` as `1` to minimize costs.
    """
    modalities: Optional[ChatCompletionModalities] = None
    audio: Optional[Audio2] = None
    """
    Parameters for audio output. Required when audio output is requested with
    `modalities: ["audio"]`. [Learn more](/docs/guides/audio).

    """
    presence_penalty: Optional[float] = Field(0, ge=-2.0, le=2.0)
    """
    Number between -2.0 and 2.0. Positive values penalize new tokens based on whether they appear in the text so far, increasing the model's likelihood to talk about new topics.

    [See more information about frequency and presence penalties.](/docs/guides/text-generation/parameter-details)

    """
    response_format: Optional[
        Union[ResponseFormatText, ResponseFormatJsonObject, ResponseFormatJsonSchema]
    ] = None
    """
    An object specifying the format that the model must output. Compatible with [GPT-4o](/docs/models/gpt-4o), [GPT-4o mini](/docs/models/gpt-4o-mini), [GPT-4 Turbo](/docs/models/gpt-4-and-gpt-4-turbo) and all GPT-3.5 Turbo models newer than `gpt-3.5-turbo-1106`.

    Setting to `{ "type": "json_schema", "json_schema": {...} }` enables Structured Outputs which ensures the model will match your supplied JSON schema. Learn more in the [Structured Outputs guide](/docs/guides/structured-outputs).

    Setting to `{ "type": "json_object" }` enables JSON mode, which ensures the message the model generates is valid JSON.

    **Important:** when using JSON mode, you **must** also instruct the model to produce JSON yourself via a system or user message. Without this, the model may generate an unending stream of whitespace until the generation reaches the token limit, resulting in a long-running and seemingly "stuck" request. Also note that the message content may be partially cut off if `finish_reason="length"`, which indicates the generation exceeded `max_tokens` or the conversation exceeded the max context length.

    """
    seed: Optional[int] = Field(None, ge=-9223372036854776000, le=9223372036854776000)
    """
    This feature is in Beta.
    If specified, our system will make a best effort to sample deterministically, such that repeated requests with the same `seed` and parameters should return the same result.
    Determinism is not guaranteed, and you should refer to the `system_fingerprint` response parameter to monitor changes in the backend.

    """
    service_tier: Optional[ServiceTier] = 'auto'
    """
    Specifies the latency tier to use for processing the request. This parameter is relevant for customers subscribed to the scale tier service:
      - If set to 'auto', and the Project is Scale tier enabled, the system will utilize scale tier credits until they are exhausted. 
      - If set to 'auto', and the Project is not Scale tier enabled, the request will be processed using the default service tier with a lower uptime SLA and no latency guarentee.
      - If set to 'default', the request will be processed using the default service tier with a lower uptime SLA and no latency guarentee.
      - When not set, the default behavior is 'auto'.

      When this parameter is set, the response body will include the `service_tier` utilized.

    """
    stop: Union[Optional[str], Stop] = None
    """
    Up to 4 sequences where the API will stop generating further tokens.

    """
    stream: Optional[bool] = False
    """
    If set, partial message deltas will be sent, like in ChatGPT. Tokens will be sent as data-only [server-sent events](https://developer.mozilla.org/en-US/docs/Web/API/Server-sent_events/Using_server-sent_events#Event_stream_format) as they become available, with the stream terminated by a `data: [DONE]` message. [Example Python code](https://cookbook.openai.com/examples/how_to_stream_completions).

    """
    stream_options: Optional[ChatCompletionStreamOptions] = None
    temperature: Optional[float] = Field(1, examples=[1], ge=0.0, le=2.0)
    """
    What sampling temperature to use, between 0 and 2. Higher values like 0.8 will make the output more random, while lower values like 0.2 will make it more focused and deterministic.

    We generally recommend altering this or `top_p` but not both.

    """
    top_p: Optional[float] = Field(1, examples=[1], ge=0.0, le=1.0)
    """
    An alternative to sampling with temperature, called nucleus sampling, where the model considers the results of the tokens with top_p probability mass. So 0.1 means only the tokens comprising the top 10% probability mass are considered.

    We generally recommend altering this or `temperature` but not both.

    """
    tools: Optional[List[ChatCompletionTool]] = None
    """
    A list of tools the model may call. Currently, only functions are supported as a tool. Use this to provide a list of functions the model may generate JSON inputs for. A max of 128 functions are supported.

    """
    tool_choice: Optional[ChatCompletionToolChoiceOption] = None
    parallel_tool_calls: Optional[ParallelToolCalls] = None
    user: Optional[str] = Field(None, examples=['user-1234'])
    """
    A unique identifier representing your end-user, which can help OpenAI to monitor and detect abuse. [Learn more](/docs/guides/safety-best-practices/end-user-ids).

    """
    function_call: Optional[Union[FunctionCall3, ChatCompletionFunctionCallOption]] = (
        None
    )
    """
    Deprecated in favor of `tool_choice`.

    Controls which (if any) function is called by the model.
    `none` means the model will not call a function and instead generates a message.
    `auto` means the model can pick between generating a message or calling a function.
    Specifying a particular function via `{"name": "my_function"}` forces the model to call that function.

    `none` is the default when no functions are present. `auto` is the default if functions are present.

    """
    functions: Optional[List[ChatCompletionFunctions]] = Field(
        None, max_length=128, min_length=1
    )
    """
    Deprecated in favor of `tools`.

    A list of functions the model may generate JSON inputs for.

    """


class CreateRunRequest(BaseModel):
    model_config = ConfigDict(
        extra='forbid',
    )
    assistant_id: str
    """
    The ID of the [assistant](/docs/api-reference/assistants) to use to execute this run.
    """
    model: Optional[Union[Optional[str], Model9]] = Field(None, examples=['gpt-4o'])
    """
    The ID of the [Model](/docs/api-reference/models) to be used to execute this run. If a value is provided here, it will override the model associated with the assistant. If not, the model associated with the assistant will be used.
    """
    instructions: Optional[str] = None
    """
    Overrides the [instructions](/docs/api-reference/assistants/createAssistant) of the assistant. This is useful for modifying the behavior on a per-run basis.
    """
    additional_instructions: Optional[str] = None
    """
    Appends additional instructions at the end of the instructions for the run. This is useful for modifying the behavior on a per-run basis without overriding other instructions.
    """
    additional_messages: Optional[List[CreateMessageRequest]] = None
    """
    Adds additional messages to the thread before creating the run.
    """
    tools: Optional[
        List[
            Union[AssistantToolsCode, AssistantToolsFileSearch, AssistantToolsFunction]
        ]
    ] = Field(None, max_length=20)
    """
    Override the tools the assistant can use for this run. This is useful for modifying the behavior on a per-run basis.
    """
    metadata: Optional[Dict[str, Any]] = None
    """
    Set of 16 key-value pairs that can be attached to an object. This can be useful for storing additional information about the object in a structured format. Keys can be a maximum of 64 characters long and values can be a maximum of 512 characters long.

    """
    temperature: Optional[float] = Field(1, examples=[1], ge=0.0, le=2.0)
    """
    What sampling temperature to use, between 0 and 2. Higher values like 0.8 will make the output more random, while lower values like 0.2 will make it more focused and deterministic.

    """
    top_p: Optional[float] = Field(1, examples=[1], ge=0.0, le=1.0)
    """
    An alternative to sampling with temperature, called nucleus sampling, where the model considers the results of the tokens with top_p probability mass. So 0.1 means only the tokens comprising the top 10% probability mass are considered.

    We generally recommend altering this or temperature but not both.

    """
    stream: Optional[bool] = None
    """
    If `true`, returns a stream of events that happen during the Run as server-sent events, terminating when the Run enters a terminal state with a `data: [DONE]` message.

    """
    max_prompt_tokens: Optional[int] = Field(None, ge=256)
    """
    The maximum number of prompt tokens that may be used over the course of the run. The run will make a best effort to use only the number of prompt tokens specified, across multiple turns of the run. If the run exceeds the number of prompt tokens specified, the run will end with status `incomplete`. See `incomplete_details` for more info.

    """
    max_completion_tokens: Optional[int] = Field(None, ge=256)
    """
    The maximum number of completion tokens that may be used over the course of the run. The run will make a best effort to use only the number of completion tokens specified, across multiple turns of the run. If the run exceeds the number of completion tokens specified, the run will end with status `incomplete`. See `incomplete_details` for more info.

    """
    truncation_strategy: Optional[TruncationObject] = None
    tool_choice: Optional[AssistantsApiToolChoiceOption] = None
    parallel_tool_calls: Optional[ParallelToolCalls] = None
    response_format: Optional[AssistantsApiResponseFormatOption] = None


class CreateThreadAndRunRequest(BaseModel):
    model_config = ConfigDict(
        extra='forbid',
    )
    assistant_id: str
    """
    The ID of the [assistant](/docs/api-reference/assistants) to use to execute this run.
    """
    thread: Optional[CreateThreadRequest] = None
    """
    If no thread is provided, an empty thread will be created.
    """
    model: Optional[Union[Optional[str], Model9]] = Field(None, examples=['gpt-4o'])
    """
    The ID of the [Model](/docs/api-reference/models) to be used to execute this run. If a value is provided here, it will override the model associated with the assistant. If not, the model associated with the assistant will be used.
    """
    instructions: Optional[str] = None
    """
    Override the default system message of the assistant. This is useful for modifying the behavior on a per-run basis.
    """
    tools: Optional[
        List[
            Union[AssistantToolsCode, AssistantToolsFileSearch, AssistantToolsFunction]
        ]
    ] = Field(None, max_length=20)
    """
    Override the tools the assistant can use for this run. This is useful for modifying the behavior on a per-run basis.
    """
    tool_resources: Optional[ToolResources2] = None
    """
    A set of resources that are used by the assistant's tools. The resources are specific to the type of tool. For example, the `code_interpreter` tool requires a list of file IDs, while the `file_search` tool requires a list of vector store IDs.

    """
    metadata: Optional[Dict[str, Any]] = None
    """
    Set of 16 key-value pairs that can be attached to an object. This can be useful for storing additional information about the object in a structured format. Keys can be a maximum of 64 characters long and values can be a maximum of 512 characters long.

    """
    temperature: Optional[float] = Field(1, examples=[1], ge=0.0, le=2.0)
    """
    What sampling temperature to use, between 0 and 2. Higher values like 0.8 will make the output more random, while lower values like 0.2 will make it more focused and deterministic.

    """
    top_p: Optional[float] = Field(1, examples=[1], ge=0.0, le=1.0)
    """
    An alternative to sampling with temperature, called nucleus sampling, where the model considers the results of the tokens with top_p probability mass. So 0.1 means only the tokens comprising the top 10% probability mass are considered.

    We generally recommend altering this or temperature but not both.

    """
    stream: Optional[bool] = None
    """
    If `true`, returns a stream of events that happen during the Run as server-sent events, terminating when the Run enters a terminal state with a `data: [DONE]` message.

    """
    max_prompt_tokens: Optional[int] = Field(None, ge=256)
    """
    The maximum number of prompt tokens that may be used over the course of the run. The run will make a best effort to use only the number of prompt tokens specified, across multiple turns of the run. If the run exceeds the number of prompt tokens specified, the run will end with status `incomplete`. See `incomplete_details` for more info.

    """
    max_completion_tokens: Optional[int] = Field(None, ge=256)
    """
    The maximum number of completion tokens that may be used over the course of the run. The run will make a best effort to use only the number of completion tokens specified, across multiple turns of the run. If the run exceeds the number of completion tokens specified, the run will end with status `incomplete`. See `incomplete_details` for more info.

    """
    truncation_strategy: Optional[TruncationObject] = None
    tool_choice: Optional[AssistantsApiToolChoiceOption] = None
    parallel_tool_calls: Optional[ParallelToolCalls] = None
    response_format: Optional[AssistantsApiResponseFormatOption] = None


class FineTuneChatCompletionRequestAssistantMessage(
    ChatCompletionRequestAssistantMessage
):
    weight: Optional[Weight] = None
    """
    Controls whether the assistant message is trained against (0 or 1)
    """
    role: Role
    """
    The role of the messages author, in this case `assistant`.
    """


class FinetuneChatRequestInput(BaseModel):
    """
    The per-line training example of a fine-tuning input file for chat models
    """

    messages: Optional[
        List[
            Union[
                ChatCompletionRequestSystemMessage,
                ChatCompletionRequestUserMessage,
                FineTuneChatCompletionRequestAssistantMessage,
                ChatCompletionRequestToolMessage,
                ChatCompletionRequestFunctionMessage,
            ]
        ]
    ] = Field(None, min_length=1)
    tools: Optional[List[ChatCompletionTool]] = None
    """
    A list of tools the model may generate JSON inputs for.
    """
    parallel_tool_calls: Optional[ParallelToolCalls] = None
    functions: Optional[List[ChatCompletionFunctions]] = Field(
        None, max_length=128, min_length=1
    )
    """
    A list of functions the model may generate JSON inputs for.
    """


class ListRunStepsResponse(BaseModel):
    object: str = Field(..., examples=['list'])
    data: List[RunStepObject]
    first_id: str = Field(..., examples=['step_abc123'])
    last_id: str = Field(..., examples=['step_abc456'])
    has_more: bool = Field(..., examples=[False])


class ModifyAssistantRequest(BaseModel):
    model_config = ConfigDict(
        extra='forbid',
    )
    model: Optional[str] = None
    """
    ID of the model to use. You can use the [List models](/docs/api-reference/models/list) API to see all of your available models, or see our [Model overview](/docs/models/overview) for descriptions of them.

    """
    name: Optional[str] = Field(None, max_length=256)
    """
    The name of the assistant. The maximum length is 256 characters.

    """
    description: Optional[str] = Field(None, max_length=512)
    """
    The description of the assistant. The maximum length is 512 characters.

    """
    instructions: Optional[str] = Field(None, max_length=256000)
    """
    The system instructions that the assistant uses. The maximum length is 256,000 characters.

    """
    tools: List[
        Union[AssistantToolsCode, AssistantToolsFileSearch, AssistantToolsFunction]
    ] = Field([], max_length=128)
    """
    A list of tool enabled on the assistant. There can be a maximum of 128 tools per assistant. Tools can be of types `code_interpreter`, `file_search`, or `function`.

    """
    tool_resources: Optional[ToolResources4] = None
    """
    A set of resources that are used by the assistant's tools. The resources are specific to the type of tool. For example, the `code_interpreter` tool requires a list of file IDs, while the `file_search` tool requires a list of vector store IDs.

    """
    metadata: Optional[Dict[str, Any]] = None
    """
    Set of 16 key-value pairs that can be attached to an object. This can be useful for storing additional information about the object in a structured format. Keys can be a maximum of 64 characters long and values can be a maximum of 512 characters long.

    """
    temperature: Optional[float] = Field(1, examples=[1], ge=0.0, le=2.0)
    """
    What sampling temperature to use, between 0 and 2. Higher values like 0.8 will make the output more random, while lower values like 0.2 will make it more focused and deterministic.

    """
    top_p: Optional[float] = Field(1, examples=[1], ge=0.0, le=1.0)
    """
    An alternative to sampling with temperature, called nucleus sampling, where the model considers the results of the tokens with top_p probability mass. So 0.1 means only the tokens comprising the top 10% probability mass are considered.

    We generally recommend altering this or temperature but not both.

    """
    response_format: Optional[AssistantsApiResponseFormatOption] = None


class RunObject(BaseModel):
    """
    Represents an execution run on a [thread](/docs/api-reference/threads).
    """

    id: str
    """
    The identifier, which can be referenced in API endpoints.
    """
    object: Object43
    """
    The object type, which is always `thread.run`.
    """
    created_at: int
    """
    The Unix timestamp (in seconds) for when the run was created.
    """
    thread_id: str
    """
    The ID of the [thread](/docs/api-reference/threads) that was executed on as a part of this run.
    """
    assistant_id: str
    """
    The ID of the [assistant](/docs/api-reference/assistants) used for execution of this run.
    """
    status: Status6
    """
    The status of the run, which can be either `queued`, `in_progress`, `requires_action`, `cancelling`, `cancelled`, `failed`, `completed`, `incomplete`, or `expired`.
    """
    required_action: Optional[RequiredAction] = Field(None)
    """
    Details on the action required to continue the run. Will be `null` if no action is required.
    """
    last_error: Optional[LastError] = Field(None)
    """
    The last error associated with this run. Will be `null` if there are no errors.
    """
    expires_at: Optional[int] = Field(None)
    """
    The Unix timestamp (in seconds) for when the run will expire.
    """
    started_at: Optional[int] = Field(None)
    """
    The Unix timestamp (in seconds) for when the run was started.
    """
    cancelled_at: Optional[int] = Field(None)
    """
    The Unix timestamp (in seconds) for when the run was cancelled.
    """
    failed_at: Optional[int] = Field(None)
    """
    The Unix timestamp (in seconds) for when the run failed.
    """
    completed_at: Optional[int] = Field(None)
    """
    The Unix timestamp (in seconds) for when the run was completed.
    """
    incomplete_details: Optional[IncompleteDetails1] = Field(None)
    """
    Details on why the run is incomplete. Will be `null` if the run is not incomplete.
    """
    model: str
    """
    The model that the [assistant](/docs/api-reference/assistants) used for this run.
    """
    instructions: str
    """
    The instructions that the [assistant](/docs/api-reference/assistants) used for this run.
    """
    tools: List[
        Union[AssistantToolsCode, AssistantToolsFileSearch, AssistantToolsFunction]
    ] = Field(..., max_length=20)
    """
    The list of tools that the [assistant](/docs/api-reference/assistants) used for this run.
    """
    metadata: Optional[Dict[str, Any]] = Field(None)
    """
    Set of 16 key-value pairs that can be attached to an object. This can be useful for storing additional information about the object in a structured format. Keys can be a maximum of 64 characters long and values can be a maximum of 512 characters long.

    """
    usage: RunCompletionUsage
    temperature: Optional[float] = None
    """
    The sampling temperature used for this run. If not set, defaults to 1.
    """
    top_p: Optional[float] = None
    """
    The nucleus sampling value used for this run. If not set, defaults to 1.
    """
    max_prompt_tokens: Optional[int] = Field(None, ge=256)
    """
    The maximum number of prompt tokens specified to have been used over the course of the run.

    """
    max_completion_tokens: Optional[int] = Field(None, ge=256)
    """
    The maximum number of completion tokens specified to have been used over the course of the run.

    """
    truncation_strategy: Optional[TruncationObject] = Field(None)
    tool_choice: Optional[AssistantsApiToolChoiceOption] = Field(None)
    parallel_tool_calls: ParallelToolCalls
    response_format: Optional[AssistantsApiResponseFormatOption] = Field(None)


class Delta1(BaseModel):
    """
    The delta containing the fields that have changed on the run step.
    """

    step_details: Optional[
        Union[
            RunStepDeltaStepDetailsMessageCreationObject,
            RunStepDeltaStepDetailsToolCallsObject,
        ]
    ] = None
    """
    The details of the run step.
    """


class RunStepDeltaObject(BaseModel):
    """
    Represents a run step delta i.e. any changed fields on a run step during streaming.

    """

    id: str
    """
    The identifier of the run step, which can be referenced in API endpoints.
    """
    object: Object44
    """
    The object type, which is always `thread.run.step.delta`.
    """
    delta: Delta1
    """
    The delta containing the fields that have changed on the run step.
    """


class RunStepStreamEvent3(BaseModel):
    """
    Occurs when parts of a [run step](/docs/api-reference/run-steps/step-object) are being streamed.
    """

    event: Event9
    data: RunStepDeltaObject


class RunStepStreamEvent(
    RootModel[
        Union[
            RunStepStreamEvent1,
            RunStepStreamEvent2,
            RunStepStreamEvent3,
            RunStepStreamEvent4,
            RunStepStreamEvent5,
            RunStepStreamEvent6,
            RunStepStreamEvent7,
        ]
    ]
):
    root: Union[
        RunStepStreamEvent1,
        RunStepStreamEvent2,
        RunStepStreamEvent3,
        RunStepStreamEvent4,
        RunStepStreamEvent5,
        RunStepStreamEvent6,
        RunStepStreamEvent7,
    ]


class RunStreamEvent1(BaseModel):
    """
    Occurs when a new [run](/docs/api-reference/runs/object) is created.
    """

    event: Event14
    data: RunObject


class RunStreamEvent2(BaseModel):
    """
    Occurs when a [run](/docs/api-reference/runs/object) moves to a `queued` status.
    """

    event: Event15
    data: RunObject


class RunStreamEvent3(BaseModel):
    """
    Occurs when a [run](/docs/api-reference/runs/object) moves to an `in_progress` status.
    """

    event: Event16
    data: RunObject


class RunStreamEvent4(BaseModel):
    """
    Occurs when a [run](/docs/api-reference/runs/object) moves to a `requires_action` status.
    """

    event: Event17
    data: RunObject


class RunStreamEvent5(BaseModel):
    """
    Occurs when a [run](/docs/api-reference/runs/object) is completed.
    """

    event: Event18
    data: RunObject


class RunStreamEvent6(BaseModel):
    """
    Occurs when a [run](/docs/api-reference/runs/object) ends with status `incomplete`.
    """

    event: Event19
    data: RunObject


class RunStreamEvent7(BaseModel):
    """
    Occurs when a [run](/docs/api-reference/runs/object) fails.
    """

    event: Event20
    data: RunObject


class RunStreamEvent8(BaseModel):
    """
    Occurs when a [run](/docs/api-reference/runs/object) moves to a `cancelling` status.
    """

    event: Event21
    data: RunObject


class RunStreamEvent9(BaseModel):
    """
    Occurs when a [run](/docs/api-reference/runs/object) is cancelled.
    """

    event: Event22
    data: RunObject


class RunStreamEvent10(BaseModel):
    """
    Occurs when a [run](/docs/api-reference/runs/object) expires.
    """

    event: Event23
    data: RunObject


class RunStreamEvent(
    RootModel[
        Union[
            RunStreamEvent1,
            RunStreamEvent2,
            RunStreamEvent3,
            RunStreamEvent4,
            RunStreamEvent5,
            RunStreamEvent6,
            RunStreamEvent7,
            RunStreamEvent8,
            RunStreamEvent9,
            RunStreamEvent10,
        ]
    ]
):
    root: Union[
        RunStreamEvent1,
        RunStreamEvent2,
        RunStreamEvent3,
        RunStreamEvent4,
        RunStreamEvent5,
        RunStreamEvent6,
        RunStreamEvent7,
        RunStreamEvent8,
        RunStreamEvent9,
        RunStreamEvent10,
    ]


class AssistantObject(BaseModel):
    """
    Represents an `assistant` that can call the model and use tools.
    """

    id: str
    """
    The identifier, which can be referenced in API endpoints.
    """
    object: Object
    """
    The object type, which is always `assistant`.
    """
    created_at: int
    """
    The Unix timestamp (in seconds) for when the assistant was created.
    """
    name: Optional[str] = Field(None, max_length=256)
    """
    The name of the assistant. The maximum length is 256 characters.

    """
    description: Optional[str] = Field(None, max_length=512)
    """
    The description of the assistant. The maximum length is 512 characters.

    """
    model: str
    """
    ID of the model to use. You can use the [List models](/docs/api-reference/models/list) API to see all of your available models, or see our [Model overview](/docs/models/overview) for descriptions of them.

    """
    instructions: Optional[str] = Field(None, max_length=256000)
    """
    The system instructions that the assistant uses. The maximum length is 256,000 characters.

    """
    tools: List[
        Union[AssistantToolsCode, AssistantToolsFileSearch, AssistantToolsFunction]
    ] = Field(..., max_length=128)
    """
    A list of tool enabled on the assistant. There can be a maximum of 128 tools per assistant. Tools can be of types `code_interpreter`, `file_search`, or `function`.

    """
    tool_resources: Optional[ToolResources] = None
    """
    A set of resources that are used by the assistant's tools. The resources are specific to the type of tool. For example, the `code_interpreter` tool requires a list of file IDs, while the `file_search` tool requires a list of vector store IDs.

    """
    metadata: Optional[Dict[str, Any]] = Field(None)
    """
    Set of 16 key-value pairs that can be attached to an object. This can be useful for storing additional information about the object in a structured format. Keys can be a maximum of 64 characters long and values can be a maximum of 512 characters long.

    """
    temperature: Optional[float] = Field(1, examples=[1], ge=0.0, le=2.0)
    """
    What sampling temperature to use, between 0 and 2. Higher values like 0.8 will make the output more random, while lower values like 0.2 will make it more focused and deterministic.

    """
    top_p: Optional[float] = Field(1, examples=[1], ge=0.0, le=1.0)
    """
    An alternative to sampling with temperature, called nucleus sampling, where the model considers the results of the tokens with top_p probability mass. So 0.1 means only the tokens comprising the top 10% probability mass are considered.

    We generally recommend altering this or temperature but not both.

    """
    response_format: Optional[AssistantsApiResponseFormatOption] = None


class AssistantStreamEvent(
    RootModel[
        Union[
            ThreadStreamEvent,
            RunStreamEvent,
            RunStepStreamEvent,
            MessageStreamEvent,
            ErrorEvent,
            DoneEvent,
        ]
    ]
):
    root: Union[
        ThreadStreamEvent,
        RunStreamEvent,
        RunStepStreamEvent,
        MessageStreamEvent,
        ErrorEvent,
        DoneEvent,
    ]
    """
    Represents an event emitted when streaming a Run.

    Each event in a server-sent events stream has an `event` and `data` property:

    ```
    event: thread.created
    data: {"id": "thread_123", "object": "thread", ...}
    ```

    We emit events whenever a new object is created, transitions to a new state, or is being
    streamed in parts (deltas). For example, we emit `thread.run.created` when a new run
    is created, `thread.run.completed` when a run completes, and so on. When an Assistant chooses
    to create a message during a run, we emit a `thread.message.created event`, a
    `thread.message.in_progress` event, many `thread.message.delta` events, and finally a
    `thread.message.completed` event.

    We may add additional events over time, so we recommend handling unknown events gracefully
    in your code. See the [Assistants API quickstart](/docs/assistants/overview) to learn how to
    integrate the Assistants API with streaming.

    """


class AuditLog(BaseModel):
    """
    A log of a user action or configuration change within this organization.
    """

    id: str
    """
    The ID of this log.
    """
    type: AuditLogEventType
    effective_at: int
    """
    The Unix timestamp (in seconds) of the event.
    """
    project: Optional[Project] = None
    """
    The project that the action was scoped to. Absent for actions not scoped to projects.
    """
    actor: AuditLogActor
    api_key_created: Optional[ApiKeyCreated] = Field(None, alias='api_key.created')
    """
    The details for events with this `type`.
    """
    api_key_updated: Optional[ApiKeyUpdated] = Field(None, alias='api_key.updated')
    """
    The details for events with this `type`.
    """
    api_key_deleted: Optional[ApiKeyDeleted] = Field(None, alias='api_key.deleted')
    """
    The details for events with this `type`.
    """
    invite_sent: Optional[InviteSent] = Field(None, alias='invite.sent')
    """
    The details for events with this `type`.
    """
    invite_accepted: Optional[InviteAccepted] = Field(None, alias='invite.accepted')
    """
    The details for events with this `type`.
    """
    invite_deleted: Optional[InviteDeleted] = Field(None, alias='invite.deleted')
    """
    The details for events with this `type`.
    """
    login_failed: Optional[LoginFailed] = Field(None, alias='login.failed')
    """
    The details for events with this `type`.
    """
    logout_failed: Optional[LogoutFailed] = Field(None, alias='logout.failed')
    """
    The details for events with this `type`.
    """
    organization_updated: Optional[OrganizationUpdated] = Field(
        None, alias='organization.updated'
    )
    """
    The details for events with this `type`.
    """
    project_created: Optional[ProjectCreated] = Field(None, alias='project.created')
    """
    The details for events with this `type`.
    """
    project_updated: Optional[ProjectUpdated] = Field(None, alias='project.updated')
    """
    The details for events with this `type`.
    """
    project_archived: Optional[ProjectArchived] = Field(None, alias='project.archived')
    """
    The details for events with this `type`.
    """
    service_account_created: Optional[ServiceAccountCreated] = Field(
        None, alias='service_account.created'
    )
    """
    The details for events with this `type`.
    """
    service_account_updated: Optional[ServiceAccountUpdated] = Field(
        None, alias='service_account.updated'
    )
    """
    The details for events with this `type`.
    """
    service_account_deleted: Optional[ServiceAccountDeleted] = Field(
        None, alias='service_account.deleted'
    )
    """
    The details for events with this `type`.
    """
    user_added: Optional[UserAdded] = Field(None, alias='user.added')
    """
    The details for events with this `type`.
    """
    user_updated: Optional[UserUpdated] = Field(None, alias='user.updated')
    """
    The details for events with this `type`.
    """
    user_deleted: Optional[UserDeleted] = Field(None, alias='user.deleted')
    """
    The details for events with this `type`.
    """


class ListAssistantsResponse(BaseModel):
    object: str = Field(..., examples=['list'])
    data: List[AssistantObject]
    first_id: str = Field(..., examples=['asst_abc123'])
    last_id: str = Field(..., examples=['asst_abc456'])
    has_more: bool = Field(..., examples=[False])


class ListAuditLogsResponse(BaseModel):
    object: Object20
    data: List[AuditLog]
    first_id: str = Field(..., examples=['audit_log-defb456h8dks'])
    last_id: str = Field(..., examples=['audit_log-hnbkd8s93s'])
    has_more: bool


class ListRunsResponse(BaseModel):
    object: str = Field(..., examples=['list'])
    data: List[RunObject]
    first_id: str = Field(..., examples=['run_abc123'])
    last_id: str = Field(..., examples=['run_abc456'])
    has_more: bool = Field(..., examples=[False])
