# Data transfer objects and exceptions

This page describes several classes that work as data transfer objects (DTOs), to be
used as input arguments for methods or functions, or as return values of these.

## Input arguments

Instances of these classes are expected as input arguments by some methods or functions
of the SDK. They contain the configuration and other details about the inference to
perform.

- imagine.ModelType[\[source\]](https://docs.qualcomm.com/doc/80-88545-1/topic/models.html#ModelType)

    - Supported values: <cite>ModelType.EMBEDDING</cite>,`ModelType.LLM`, <cite>ModelType.RERANKER</cite>, <cite>ModelType.TEXT_TO_IMAGE</cite>, <cite>ModelType.TRANSCRIBE</cite>, <cite>ModelType.TRANSLATE</cite>.

- *class* imagine.ReRankerRequest(*\**, *query*, *documents*, *top\_n=None*, *model*, *return\_documents=None*)[\[source\]](https://docs.qualcomm.com/doc/80-88545-1/topic/reranker.html#ReRankerRequest)

    - - documents*: [list](https://docs.python.org/3/library/stdtypes.html#list "(in Python v3.14)")[[str](https://docs.python.org/3/library/stdtypes.html#str "(in Python v3.14)")]*

    - A list of document IDs or text

- model*: [str](https://docs.python.org/3/library/stdtypes.html#str "(in Python v3.14)")*

    - The name of the model to use for re-ranking

- query*: [str](https://docs.python.org/3/library/stdtypes.html#str "(in Python v3.14)")*

    - The query string to be used for re-ranking

- return\_documents*: [bool](https://docs.python.org/3/library/functions.html#bool "(in Python v3.14)") | [None](https://docs.python.org/3/library/constants.html#None "(in Python v3.14)")*

    - Whether to return the documents themselves (default: False)

- top\_n*: [int](https://docs.python.org/3/library/functions.html#int "(in Python v3.14)") | [None](https://docs.python.org/3/library/constants.html#None "(in Python v3.14)")*

    - The number of top results to return (default: 1)

- *class* imagine.ChatMessage(*\**, *role*, *content*, *tool\_calls=None*, *tool\_call\_id=None*, *name=None*)[\[source\]](https://docs.qualcomm.com/doc/80-88545-1/topic/chat_completions.html#ChatMessage)

    - - content*: [str](https://docs.python.org/3/library/stdtypes.html#str "(in Python v3.14)") | [list](https://docs.python.org/3/library/stdtypes.html#list "(in Python v3.14)")[[dict](https://docs.python.org/3/library/stdtypes.html#dict "(in Python v3.14)")[[str](https://docs.python.org/3/library/stdtypes.html#str "(in Python v3.14)"), Any]] | [None](https://docs.python.org/3/library/constants.html#None "(in Python v3.14)")*

    - The content of the message

- name*: [str](https://docs.python.org/3/library/stdtypes.html#str "(in Python v3.14)") | [None](https://docs.python.org/3/library/constants.html#None "(in Python v3.14)")*

    - An optional name for the participant.

- role*: [str](https://docs.python.org/3/library/stdtypes.html#str "(in Python v3.14)")*

    - The role of the message <cite>user</cite>, <cite>assistant</cite>, <cite>system</cite>, <cite>tool</cite>

- tool\_call\_id*: [str](https://docs.python.org/3/library/stdtypes.html#str "(in Python v3.14)") | [None](https://docs.python.org/3/library/constants.html#None "(in Python v3.14)")*

    - The ID of the tool call.

- tool\_calls*: [list](https://docs.python.org/3/library/stdtypes.html#list "(in Python v3.14)")[ChatMessageToolCall] | [None](https://docs.python.org/3/library/constants.html#None "(in Python v3.14)")*

    - The tool calls generated by the model, such as function calls

- *class* imagine.ChatCompletionRequest(*\**, *frequency\_penalty=None*, *presence\_penalty=None*, *repetition\_penalty=None*, *stop=None*, *max\_seconds=None*, *ignore\_eos=None*, *skip\_special\_tokens=None*, *stop\_token\_ids=None*, *max\_tokens=None*, *temperature=None*, *top\_k=None*, *top\_p=None*, *stream\_options=None*, *messages*, *model*, *stream*, *tools=None*)[\[source\]](https://docs.qualcomm.com/doc/80-88545-1/topic/chat_completions.html#ChatCompletionRequest)

    - Bases: `LLMSamplingParams`

- frequency\_penalty*: [float](https://docs.python.org/3/library/functions.html#float "(in Python v3.14)") | [None](https://docs.python.org/3/library/constants.html#None "(in Python v3.14)")*

    - 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, defaults to None

- ignore\_eos*: [bool](https://docs.python.org/3/library/functions.html#bool "(in Python v3.14)") | [None](https://docs.python.org/3/library/constants.html#None "(in Python v3.14)")*

    - Whether to ignore the EOS token and continue generating tokens after the EOS token is generated., defaults to None

- max\_seconds*: [int](https://docs.python.org/3/library/functions.html#int "(in Python v3.14)") | [None](https://docs.python.org/3/library/constants.html#None "(in Python v3.14)")*

    - TBD, defaults to None

- max\_tokens*: [int](https://docs.python.org/3/library/functions.html#int "(in Python v3.14)") | [None](https://docs.python.org/3/library/constants.html#None "(in Python v3.14)")*

    - The maximum number of tokens that can be generated, defaults to None

- messages*: [list](https://docs.python.org/3/library/stdtypes.html#list "(in Python v3.14)")[[ChatMessage](https://docs.qualcomm.com/doc/80-88545-1/topic/dtos.html#imagine.ChatMessage)]*

    - A list of [messages]

- model*: [str](https://docs.python.org/3/library/stdtypes.html#str "(in Python v3.14)")*

    - The model to be used for the chat completion.

- presence\_penalty*: [float](https://docs.python.org/3/library/functions.html#float "(in Python v3.14)") | [None](https://docs.python.org/3/library/constants.html#None "(in Python v3.14)")*

    - 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, defaults to None

- repetition\_penalty*: [float](https://docs.python.org/3/library/functions.html#float "(in Python v3.14)") | [None](https://docs.python.org/3/library/constants.html#None "(in Python v3.14)")*

    - Float that penalizes new tokens based on whether they appear in the prompt and the generated text so far. Values &gt; 1 encourage the model to use new tokens, while values &lt; 1 encourage the model to repeat tokens., defaults to None

- skip\_special\_tokens*: [bool](https://docs.python.org/3/library/functions.html#bool "(in Python v3.14)") | [None](https://docs.python.org/3/library/constants.html#None "(in Python v3.14)")*

    - Whether to skip special tokens in the output., defaults to None

- stop*: [list](https://docs.python.org/3/library/stdtypes.html#list "(in Python v3.14)")[[str](https://docs.python.org/3/library/stdtypes.html#str "(in Python v3.14)")] | [None](https://docs.python.org/3/library/constants.html#None "(in Python v3.14)")*

    - Sequences where the API will stop generating further tokens. The returned text will contain the stop sequence., defaults to None

- stop\_token\_ids*: [list](https://docs.python.org/3/library/stdtypes.html#list "(in Python v3.14)")[[list](https://docs.python.org/3/library/stdtypes.html#list "(in Python v3.14)")[[int](https://docs.python.org/3/library/functions.html#int "(in Python v3.14)")]] | [None](https://docs.python.org/3/library/constants.html#None "(in Python v3.14)")*

    - List of tokens that stop the generation when they are generated. The returned output will contain the stop tokens unless the stop tokens are special tokens., defaults to None

- stream*: [bool](https://docs.python.org/3/library/functions.html#bool "(in Python v3.14)")*

    - If set, partial message deltas will be sent

- stream\_options*: [dict](https://docs.python.org/3/library/stdtypes.html#dict "(in Python v3.14)")[[str](https://docs.python.org/3/library/stdtypes.html#str "(in Python v3.14)"), Any] | [None](https://docs.python.org/3/library/constants.html#None "(in Python v3.14)")*

    - Configure streaming outputs, like whether to return token usage when streaming (`{"include_usage": True}`).

- temperature*: [float](https://docs.python.org/3/library/functions.html#float "(in Python v3.14)") | [None](https://docs.python.org/3/library/constants.html#None "(in Python v3.14)")*

    - 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., defaults to None

- top\_k*: [int](https://docs.python.org/3/library/functions.html#int "(in Python v3.14)") | [None](https://docs.python.org/3/library/constants.html#None "(in Python v3.14)")*

    - Integer that controls the number of top tokens to consider. Set to -1 to consider all tokens., defaults to None

- top\_p*: [float](https://docs.python.org/3/library/functions.html#float "(in Python v3.14)") | [None](https://docs.python.org/3/library/constants.html#None "(in Python v3.14)")*

    - 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 <cite>temperature</cite> but not both., defaults to None

- *class* imagine.EmbeddingRequest(*\**, *id*, *input*, *model*)[\[source\]](https://docs.qualcomm.com/doc/80-88545-1/topic/types_embeddings.html#EmbeddingRequest)

    - - id*: [str](https://docs.python.org/3/library/stdtypes.html#str "(in Python v3.14)") | [None](https://docs.python.org/3/library/constants.html#None "(in Python v3.14)")*

    - Unique object identifier.

- input*: [str](https://docs.python.org/3/library/stdtypes.html#str "(in Python v3.14)")*

    - Input string for which embedding should be generated

- model*: [str](https://docs.python.org/3/library/stdtypes.html#str "(in Python v3.14)")*

    - Model to be used for generation of embedding

- *class* imagine.CompletionRequest(*\**, *frequency\_penalty=None*, *presence\_penalty=None*, *repetition\_penalty=None*, *stop=None*, *max\_seconds=None*, *ignore\_eos=None*, *skip\_special\_tokens=None*, *stop\_token\_ids=None*, *max\_tokens=None*, *temperature=None*, *top\_k=None*, *top\_p=None*, *stream\_options=None*, *prompt*, *model*, *stream*)[\[source\]](https://docs.qualcomm.com/doc/80-88545-1/topic/completions.html#CompletionRequest)

    - Bases: `LLMSamplingParams`

- frequency\_penalty*: [float](https://docs.python.org/3/library/functions.html#float "(in Python v3.14)") | [None](https://docs.python.org/3/library/constants.html#None "(in Python v3.14)")*

    - 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, defaults to None

- ignore\_eos*: [bool](https://docs.python.org/3/library/functions.html#bool "(in Python v3.14)") | [None](https://docs.python.org/3/library/constants.html#None "(in Python v3.14)")*

    - Whether to ignore the EOS token and continue generating tokens after the EOS token is generated., defaults to None

- max\_seconds*: [int](https://docs.python.org/3/library/functions.html#int "(in Python v3.14)") | [None](https://docs.python.org/3/library/constants.html#None "(in Python v3.14)")*

    - TBD, defaults to None

- max\_tokens*: [int](https://docs.python.org/3/library/functions.html#int "(in Python v3.14)") | [None](https://docs.python.org/3/library/constants.html#None "(in Python v3.14)")*

    - The maximum number of tokens that can be generated, defaults to None

- model*: [str](https://docs.python.org/3/library/stdtypes.html#str "(in Python v3.14)")*

    - Model to be used for Completion Request

- presence\_penalty*: [float](https://docs.python.org/3/library/functions.html#float "(in Python v3.14)") | [None](https://docs.python.org/3/library/constants.html#None "(in Python v3.14)")*

    - 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, defaults to None

- prompt*: [str](https://docs.python.org/3/library/stdtypes.html#str "(in Python v3.14)")*

    - Prompt for completion request

- repetition\_penalty*: [float](https://docs.python.org/3/library/functions.html#float "(in Python v3.14)") | [None](https://docs.python.org/3/library/constants.html#None "(in Python v3.14)")*

    - Float that penalizes new tokens based on whether they appear in the prompt and the generated text so far. Values &gt; 1 encourage the model to use new tokens, while values &lt; 1 encourage the model to repeat tokens., defaults to None

- skip\_special\_tokens*: [bool](https://docs.python.org/3/library/functions.html#bool "(in Python v3.14)") | [None](https://docs.python.org/3/library/constants.html#None "(in Python v3.14)")*

    - Whether to skip special tokens in the output., defaults to None

- stop*: [list](https://docs.python.org/3/library/stdtypes.html#list "(in Python v3.14)")[[str](https://docs.python.org/3/library/stdtypes.html#str "(in Python v3.14)")] | [None](https://docs.python.org/3/library/constants.html#None "(in Python v3.14)")*

    - Sequences where the API will stop generating further tokens. The returned text will contain the stop sequence., defaults to None

- stop\_token\_ids*: [list](https://docs.python.org/3/library/stdtypes.html#list "(in Python v3.14)")[[list](https://docs.python.org/3/library/stdtypes.html#list "(in Python v3.14)")[[int](https://docs.python.org/3/library/functions.html#int "(in Python v3.14)")]] | [None](https://docs.python.org/3/library/constants.html#None "(in Python v3.14)")*

    - List of tokens that stop the generation when they are generated. The returned output will contain the stop tokens unless the stop tokens are special tokens., defaults to None

- stream*: [bool](https://docs.python.org/3/library/functions.html#bool "(in Python v3.14)")*

    - Should it be a Streaming Request

- stream\_options*: [dict](https://docs.python.org/3/library/stdtypes.html#dict "(in Python v3.14)")[[str](https://docs.python.org/3/library/stdtypes.html#str "(in Python v3.14)"), Any] | [None](https://docs.python.org/3/library/constants.html#None "(in Python v3.14)")*

    - Configure streaming outputs, like whether to return token usage when streaming (`{"include_usage": True}`).

- temperature*: [float](https://docs.python.org/3/library/functions.html#float "(in Python v3.14)") | [None](https://docs.python.org/3/library/constants.html#None "(in Python v3.14)")*

    - 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., defaults to None

- top\_k*: [int](https://docs.python.org/3/library/functions.html#int "(in Python v3.14)") | [None](https://docs.python.org/3/library/constants.html#None "(in Python v3.14)")*

    - Integer that controls the number of top tokens to consider. Set to -1 to consider all tokens., defaults to None

- top\_p*: [float](https://docs.python.org/3/library/functions.html#float "(in Python v3.14)") | [None](https://docs.python.org/3/library/constants.html#None "(in Python v3.14)")*

    - 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 <cite>temperature</cite> but not both., defaults to None

## Responses

Instances of these classes are returned by some methods or functions of the SDK. They
contain the data
the user is interested into.

- *class* imagine.EmbeddingResponse(*\**, *id*, *object*, *data*, *model*, *usage*)[\[source\]](https://docs.qualcomm.com/doc/80-88545-1/topic/types_embeddings.html#EmbeddingResponse)

    - - *property* first\_embedding*: [list](https://docs.python.org/3/library/stdtypes.html#list "(in Python v3.14)")[[float](https://docs.python.org/3/library/functions.html#float "(in Python v3.14)")]*

    - Gets the first content from the response

- Returns:

    - embedding content

- id*: [str](https://docs.python.org/3/library/stdtypes.html#str "(in Python v3.14)")*

    - Unique object identifier.

- model*: [str](https://docs.python.org/3/library/stdtypes.html#str "(in Python v3.14)")*

    - Model name used.

- object*: [str](https://docs.python.org/3/library/stdtypes.html#str "(in Python v3.14)")*

    - The object type, which is always “list”.

- *class* imagine.TranslateResponse(*\**, *id*, *object*, *created*, *model*, *choices*, *usage=None*, *generation\_time=None*)[\[source\]](https://docs.qualcomm.com/doc/80-88545-1/topic/translate.html#TranslateResponse)

    - 

- *class* imagine.ReRankerResponse(*\**, *id*, *data*, *failure=None*, *model*, *object*, *usage*)[\[source\]](https://docs.qualcomm.com/doc/80-88545-1/topic/reranker.html#ReRankerResponse)

    - - data*: [list](https://docs.python.org/3/library/stdtypes.html#list "(in Python v3.14)")[ReRankerObject]*

    - A list of ReRankerObject objects

- failure*: [str](https://docs.python.org/3/library/stdtypes.html#str "(in Python v3.14)") | [None](https://docs.python.org/3/library/constants.html#None "(in Python v3.14)")*

    - An error message if the request failed

- id*: [str](https://docs.python.org/3/library/stdtypes.html#str "(in Python v3.14)")*

    - A unique identifier for the response

- model*: [str](https://docs.python.org/3/library/stdtypes.html#str "(in Python v3.14)")*

    - The name of the model used to generate the response

- object*: [str](https://docs.python.org/3/library/stdtypes.html#str "(in Python v3.14)")*

    - The type of object being returned

- usage*: [UsageInfo](https://docs.qualcomm.com/doc/80-88545-1/topic/dtos.html#imagine.UsageInfo)*

    - Information about the usage of the model

- *class* imagine.HealthResponse(*\**, *postgres*, *redis*, *models*)[\[source\]](https://docs.qualcomm.com/doc/80-88545-1/topic/healthcheck.html#HealthResponse)

    - - models*: [str](https://docs.python.org/3/library/stdtypes.html#str "(in Python v3.14)")*

    - Status of Models

- postgres*: [str](https://docs.python.org/3/library/stdtypes.html#str "(in Python v3.14)")*

    - Status of Postgres

- redis*: [str](https://docs.python.org/3/library/stdtypes.html#str "(in Python v3.14)")*

    - Status of Redis

- *class* imagine.PingResponse(*\**, *message*, *status*)[\[source\]](https://docs.qualcomm.com/doc/80-88545-1/topic/healthcheck.html#PingResponse)

    - - message*: [str](https://docs.python.org/3/library/stdtypes.html#str "(in Python v3.14)")*

    - Ping Message

- status*: [str](https://docs.python.org/3/library/stdtypes.html#str "(in Python v3.14)")*

    - Status

- *class* imagine.UsageResponse(*\**, *usage*, *overall*)[\[source\]](https://docs.qualcomm.com/doc/80-88545-1/topic/usage.html#UsageResponse)

    - - overall*: [list](https://docs.python.org/3/library/stdtypes.html#list "(in Python v3.14)")[UsageRecordAggregated]*

    - list of overall usage per record type

- usage*: [list](https://docs.python.org/3/library/stdtypes.html#list "(in Python v3.14)")[UsageRecord]*

    - list of usage record

- *class* imagine.CompletionResponse(*\**, *id*, *object*, *created*, *model*, *choices*, *usage=None*, *generation\_time=None*)[\[source\]](https://docs.qualcomm.com/doc/80-88545-1/topic/completions.html#CompletionResponse)

    - - choices*: [list](https://docs.python.org/3/library/stdtypes.html#list "(in Python v3.14)")[CompletionResponseChoice]*

    - A list of chat completion choices

- created*: [float](https://docs.python.org/3/library/functions.html#float "(in Python v3.14)")*

    - The Unix timestamp of when the completion was created.

- *property* first\_text*: [str](https://docs.python.org/3/library/stdtypes.html#str "(in Python v3.14)") | [None](https://docs.python.org/3/library/constants.html#None "(in Python v3.14)")*

    - Gets the first text from the response

- Returns:

    - text

- generation\_time*: [float](https://docs.python.org/3/library/functions.html#float "(in Python v3.14)") | [None](https://docs.python.org/3/library/constants.html#None "(in Python v3.14)")*

    - generation time.

- id*: [str](https://docs.python.org/3/library/stdtypes.html#str "(in Python v3.14)")*

    - A unique identifier for the completion.

- model*: [str](https://docs.python.org/3/library/stdtypes.html#str "(in Python v3.14)")*

    - The model used for the completion.

- object*: [str](https://docs.python.org/3/library/stdtypes.html#str "(in Python v3.14)")*

    - The object type, which is always <cite>completion</cite>.

- usage*: [UsageInfo](https://docs.qualcomm.com/doc/80-88545-1/topic/dtos.html#imagine.UsageInfo) | [None](https://docs.python.org/3/library/constants.html#None "(in Python v3.14)")*

    - Usage Statistics

- *class* imagine.CompletionStreamResponse(*\**, *id*, *model*, *choices*, *created=None*, *object=None*, *usage=None*)[\[source\]](https://docs.qualcomm.com/doc/80-88545-1/topic/completions.html#CompletionStreamResponse)

    - - choices*: [list](https://docs.python.org/3/library/stdtypes.html#list "(in Python v3.14)")[CompletionResponseStreamChoice]*

    - A list of completion choices

- created*: [float](https://docs.python.org/3/library/functions.html#float "(in Python v3.14)") | [None](https://docs.python.org/3/library/constants.html#None "(in Python v3.14)")*

    - The Unix timestamp of when the completion was created.

- *property* first\_content*: [str](https://docs.python.org/3/library/stdtypes.html#str "(in Python v3.14)") | [None](https://docs.python.org/3/library/constants.html#None "(in Python v3.14)")*

    - Gets the first content from the response

- Returns:

    - message content

- id*: [str](https://docs.python.org/3/library/stdtypes.html#str "(in Python v3.14)")*

    - A unique identifier for the completion

- model*: [str](https://docs.python.org/3/library/stdtypes.html#str "(in Python v3.14)")*

    - The model used for the completion.

- object*: [str](https://docs.python.org/3/library/stdtypes.html#str "(in Python v3.14)") | [None](https://docs.python.org/3/library/constants.html#None "(in Python v3.14)")*

    - The object type, which is always <cite>chat.completion.chunk</cite>

- usage*: [UsageInfo](https://docs.qualcomm.com/doc/80-88545-1/topic/dtos.html#imagine.UsageInfo) | [None](https://docs.python.org/3/library/constants.html#None "(in Python v3.14)")*

    - Usage statistics for the completion request.

- *class* imagine.ChatCompletionResponse(*\**, *id*, *object*, *created*, *model*, *choices*, *usage*)[\[source\]](https://docs.qualcomm.com/doc/80-88545-1/topic/chat_completions.html#ChatCompletionResponse)

    - - choices*: [list](https://docs.python.org/3/library/stdtypes.html#list "(in Python v3.14)")[[ChatCompletionResponseChoice](https://docs.qualcomm.com/doc/80-88545-1/topic/dtos.html#imagine.ChatCompletionResponseChoice)]*

    - A list of chat completion choices

- created*: [float](https://docs.python.org/3/library/functions.html#float "(in Python v3.14)")*

    - The Unix timestamp of when the chat completion was created.

- *property* first\_content*: [str](https://docs.python.org/3/library/stdtypes.html#str "(in Python v3.14)") | [None](https://docs.python.org/3/library/constants.html#None "(in Python v3.14)")*

    - Gets the first content from the response

- Returns:

    - message content

- id*: [str](https://docs.python.org/3/library/stdtypes.html#str "(in Python v3.14)")*

    - A unique identifier for the chat completion.

- model*: [str](https://docs.python.org/3/library/stdtypes.html#str "(in Python v3.14)")*

    - The model used for the chat completion.

- object*: [str](https://docs.python.org/3/library/stdtypes.html#str "(in Python v3.14)")*

    - The object type, which is always <cite>chat.completion</cite>.

- usage*: [UsageInfo](https://docs.qualcomm.com/doc/80-88545-1/topic/dtos.html#imagine.UsageInfo)*

    - Usage statistics for the completion request.

- *class* imagine.ChatCompletionResponseChoice(*\**, *index*, *message*, *finish\_reason*)[\[source\]](https://docs.qualcomm.com/doc/80-88545-1/topic/chat_completions.html#ChatCompletionResponseChoice)

    - - finish\_reason*: [FinishReason](https://docs.qualcomm.com/doc/80-88545-1/topic/dtos.html#imagine.FinishReason) | [None](https://docs.python.org/3/library/constants.html#None "(in Python v3.14)")*

    - The reason the model stopped generating tokens.
This will be <cite>stop</cite> if the model hit a natural stop point or a provided stop sequence,
<cite>length</cite> if the maximum number of tokens specified in the request was reached
<cite>error</cite> in case of error

- index*: [int](https://docs.python.org/3/library/functions.html#int "(in Python v3.14)")*

    - The index of the choice in the list of choices.

- message*: [ChatMessage](https://docs.qualcomm.com/doc/80-88545-1/topic/dtos.html#imagine.ChatMessage)*

    - A chat completion message generated by the model.

- *class* imagine.ChatCompletionStreamResponse(*\**, *id*, *model*, *choices*, *created=None*, *object=None*, *usage=None*)[\[source\]](https://docs.qualcomm.com/doc/80-88545-1/topic/chat_completions.html#ChatCompletionStreamResponse)

    - - choices*: [list](https://docs.python.org/3/library/stdtypes.html#list "(in Python v3.14)")[[ChatCompletionResponseStreamChoice](https://docs.qualcomm.com/doc/80-88545-1/topic/dtos.html#imagine.ChatCompletionResponseStreamChoice)]*

    - A list of chat completion choices

- created*: [float](https://docs.python.org/3/library/functions.html#float "(in Python v3.14)") | [None](https://docs.python.org/3/library/constants.html#None "(in Python v3.14)")*

    - The Unix timestamp of when the chat completion was created.

- *property* first\_content*: [str](https://docs.python.org/3/library/stdtypes.html#str "(in Python v3.14)") | [None](https://docs.python.org/3/library/constants.html#None "(in Python v3.14)")*

    - Gets the first content from the response

- Returns:

    - message content

- id*: [str](https://docs.python.org/3/library/stdtypes.html#str "(in Python v3.14)")*

    - A unique identifier for the chat completion

- model*: [str](https://docs.python.org/3/library/stdtypes.html#str "(in Python v3.14)")*

    - The model used for the chat completion.

- object*: [str](https://docs.python.org/3/library/stdtypes.html#str "(in Python v3.14)") | [None](https://docs.python.org/3/library/constants.html#None "(in Python v3.14)")*

    - The object type, which is always <cite>chat.completion.chunk</cite>.

- usage*: [UsageInfo](https://docs.qualcomm.com/doc/80-88545-1/topic/dtos.html#imagine.UsageInfo) | [None](https://docs.python.org/3/library/constants.html#None "(in Python v3.14)")*

    - Usage statistics for the completion request.

- *class* imagine.TranscribeResponse(*\**, *generation\_time*, *id*, *text*, *ts*)[\[source\]](https://docs.qualcomm.com/doc/80-88545-1/topic/transcribe.html#TranscribeResponse)

    - - generation\_time*: [float](https://docs.python.org/3/library/functions.html#float "(in Python v3.14)")*

    - Time taken to generate the response (In seconds)

- id*: [str](https://docs.python.org/3/library/stdtypes.html#str "(in Python v3.14)")*

    - ID of the transcription request

- text*: [str](https://docs.python.org/3/library/stdtypes.html#str "(in Python v3.14)")*

    - Audio transcription

- ts*: [str](https://docs.python.org/3/library/stdtypes.html#str "(in Python v3.14)") | [None](https://docs.python.org/3/library/constants.html#None "(in Python v3.14)")*

    - The timestamp of when the response was generated

- *class* imagine.ImageResponse(*\**, *id*, *model*, *object*, *created*, *data*)[\[source\]](https://docs.qualcomm.com/doc/80-88545-1/topic/images.html#ImageResponse)

    - - created*: [float](https://docs.python.org/3/library/functions.html#float "(in Python v3.14)")*

    - The Unix timestamp of when the completion was created.

- data*: [list](https://docs.python.org/3/library/stdtypes.html#list "(in Python v3.14)")[Image]*

    - Data object which is a list of Image objects.

- model*: [str](https://docs.python.org/3/library/stdtypes.html#str "(in Python v3.14)")*

    - Model used for Image Generation

- object*: [str](https://docs.python.org/3/library/stdtypes.html#str "(in Python v3.14)")*

    - The object type, which is always <cite>text_to_image</cite>.

- *class* imagine.ChatCompletionResponseStreamChoice(*\**, *index*, *delta*, *finish\_reason*)[\[source\]](https://docs.qualcomm.com/doc/80-88545-1/topic/chat_completions.html#ChatCompletionResponseStreamChoice)

    - - delta*: [DeltaMessage](https://docs.qualcomm.com/doc/80-88545-1/topic/dtos.html#imagine.DeltaMessage)*

    - A chat completion delta generated by streamed model responses.

- finish\_reason*: [FinishReason](https://docs.qualcomm.com/doc/80-88545-1/topic/dtos.html#imagine.FinishReason) | [None](https://docs.python.org/3/library/constants.html#None "(in Python v3.14)")*

    - The reason the model stopped generating tokens.
This will be <cite>stop</cite> if the model hit a natural stop point or a provided stop sequence,
<cite>length</cite> if the maximum number of tokens specified in the request was reached
<cite>error</cite> in case of error

- index*: [int](https://docs.python.org/3/library/functions.html#int "(in Python v3.14)")*

    - The index of the choice in the list of choices.

- *class* imagine.DeltaMessage(*\**, *role=None*, *content=None*)[\[source\]](https://docs.qualcomm.com/doc/80-88545-1/topic/common.html#DeltaMessage)

    - - content*: [str](https://docs.python.org/3/library/stdtypes.html#str "(in Python v3.14)") | [None](https://docs.python.org/3/library/constants.html#None "(in Python v3.14)")*

    - The content of the message

- role*: [str](https://docs.python.org/3/library/stdtypes.html#str "(in Python v3.14)") | [None](https://docs.python.org/3/library/constants.html#None "(in Python v3.14)")*

    - The role of the message <cite>user</cite>, <cite>assistant</cite>, <cite>system</cite>

- *class* imagine.FinishReason(*value*, *names=&lt;not given&gt;*, *\*values*, *module=None*, *qualname=None*, *type=None*, *start=1*, *boundary=None*)[\[source\]](https://docs.qualcomm.com/doc/80-88545-1/topic/common.html#FinishReason)

    - 

- *class* imagine.UsageInfo(*\**, *prompt\_tokens=None*, *total\_tokens=None*, *completion\_tokens=None*)[\[source\]](https://docs.qualcomm.com/doc/80-88545-1/topic/common.html#UsageInfo)

    - - completion\_tokens*: [int](https://docs.python.org/3/library/functions.html#int "(in Python v3.14)") | [None](https://docs.python.org/3/library/constants.html#None "(in Python v3.14)")*

    - Number of tokens in the generated completion

- prompt\_tokens*: [int](https://docs.python.org/3/library/functions.html#int "(in Python v3.14)") | [None](https://docs.python.org/3/library/constants.html#None "(in Python v3.14)")*

    - Number of tokens in the prompt

- total\_tokens*: [int](https://docs.python.org/3/library/functions.html#int "(in Python v3.14)") | [None](https://docs.python.org/3/library/constants.html#None "(in Python v3.14)")*

    - Total number of tokens used in the request (prompt + completion).

## Exceptions

The following are exceptions returned by the SDK:

- *class* imagine.ImagineException(*message=None*)[\[source\]](https://docs.qualcomm.com/doc/80-88545-1/topic/exceptions.html#ImagineException)

    - Base Exception class, returned when nothing more specific applies

- *class* imagine.ImagineAPITooManyRequestsException(*message=None*, *http\_status=None*, *headers=None*)[\[source\]](https://docs.qualcomm.com/doc/80-88545-1/topic/exceptions.html#ImagineAPITooManyRequestsException)

    - Returned when we receive a 429 response from the API, indicating that we probably hit a rate limit

## Next steps

- Review [adding guardrails to an LLM](https://docs.qualcomm.com/doc/80-88545-1/topic/dtos.html#guarded_llm_example.md) for examples using `chat_completion` and `completion_response`.
- Review the methods of the [Imagine clients](https://docs.qualcomm.com/doc/80-88545-1/topic/imagine_clients.html) to learn what raises the exceptions returned by the SDK.

Last Published: Apr 17, 2026

[Previous Topic
Imagine clients](https://docs.qualcomm.com/bundle/publicresource/80-88545-1/topics/imagine_clients.md) [Next Topic
LangChain](https://docs.qualcomm.com/bundle/publicresource/80-88545-1/topics/langchain.md)