## Create Completion `chat.create_completion(ChatCreateCompletionParams**kwargs) -> object` **post** `/chat/completions` Create Chat Completion ### Parameters - `messages: Iterable[Message]` - `class MessageChatCompletionDeveloperMessageParam: …` Developer-provided instructions that the model should follow, regardless of messages sent by the user. With o1 models and newer, `developer` messages replace the previous `system` messages. - `content: Union[str, Iterable[MessageChatCompletionDeveloperMessageParamContentUnionMember1]]` - `str` - `Iterable[MessageChatCompletionDeveloperMessageParamContentUnionMember1]` - `text: str` - `type: Literal["text"]` - `"text"` - `role: Literal["developer"]` - `"developer"` - `name: Optional[str]` - `class MessageChatCompletionSystemMessageParam: …` Developer-provided instructions that the model should follow, regardless of messages sent by the user. With o1 models and newer, use `developer` messages for this purpose instead. - `content: Union[str, Iterable[MessageChatCompletionSystemMessageParamContentUnionMember1]]` - `str` - `Iterable[MessageChatCompletionSystemMessageParamContentUnionMember1]` - `text: str` - `type: Literal["text"]` - `"text"` - `role: Literal["system"]` - `"system"` - `name: Optional[str]` - `class MessageChatCompletionUserMessageParam: …` Messages sent by an end user, containing prompts or additional context information. - `content: Union[str, Iterable[MessageChatCompletionUserMessageParamContentUnionMember1]]` - `str` - `Iterable[MessageChatCompletionUserMessageParamContentUnionMember1]` - `class MessageChatCompletionUserMessageParamContentUnionMember1ChatCompletionContentPartTextParam: …` Learn about [text inputs](https://platform.openai.com/docs/guides/text-generation). - `text: str` - `type: Literal["text"]` - `"text"` - `class MessageChatCompletionUserMessageParamContentUnionMember1ChatCompletionContentPartImageParam: …` Learn about [image inputs](https://platform.openai.com/docs/guides/vision). - `image_url: MessageChatCompletionUserMessageParamContentUnionMember1ChatCompletionContentPartImageParamImageURL` - `url: str` - `detail: Optional[Literal["auto", "low", "high"]]` - `"auto"` - `"low"` - `"high"` - `type: Literal["image_url"]` - `"image_url"` - `class MessageChatCompletionUserMessageParamContentUnionMember1ChatCompletionContentPartInputAudioParam: …` Learn about [audio inputs](https://platform.openai.com/docs/guides/audio). - `input_audio: MessageChatCompletionUserMessageParamContentUnionMember1ChatCompletionContentPartInputAudioParamInputAudio` - `data: str` - `format: Literal["wav", "mp3"]` - `"wav"` - `"mp3"` - `type: Literal["input_audio"]` - `"input_audio"` - `class MessageChatCompletionUserMessageParamContentUnionMember1File: …` Learn about [file inputs](https://platform.openai.com/docs/guides/text) for text generation. - `file: MessageChatCompletionUserMessageParamContentUnionMember1FileFile` - `file_data: Optional[str]` - `file_id: Optional[str]` - `filename: Optional[str]` - `type: Literal["file"]` - `"file"` - `role: Literal["user"]` - `"user"` - `name: Optional[str]` - `class MessageChatCompletionAssistantMessageParam: …` Messages sent by the model in response to user messages. - `role: Literal["assistant"]` - `"assistant"` - `audio: Optional[MessageChatCompletionAssistantMessageParamAudio]` Data about a previous audio response from the model. [Learn more](https://platform.openai.com/docs/guides/audio). - `id: str` - `content: Optional[Union[str, Iterable[MessageChatCompletionAssistantMessageParamContentUnionMember1], null]]` - `str` - `Iterable[MessageChatCompletionAssistantMessageParamContentUnionMember1]` - `class MessageChatCompletionAssistantMessageParamContentUnionMember1ChatCompletionContentPartTextParam: …` Learn about [text inputs](https://platform.openai.com/docs/guides/text-generation). - `text: str` - `type: Literal["text"]` - `"text"` - `class MessageChatCompletionAssistantMessageParamContentUnionMember1ChatCompletionContentPartRefusalParam: …` - `refusal: str` - `type: Literal["refusal"]` - `"refusal"` - `function_call: Optional[MessageChatCompletionAssistantMessageParamFunctionCall]` Deprecated and replaced by `tool_calls`. The name and arguments of a function that should be called, as generated by the model. - `arguments: str` - `name: str` - `name: Optional[str]` - `refusal: Optional[str]` - `tool_calls: Optional[Iterable[MessageChatCompletionAssistantMessageParamToolCall]]` - `class MessageChatCompletionAssistantMessageParamToolCallChatCompletionMessageFunctionToolCallParam: …` A call to a function tool created by the model. - `id: str` - `function: MessageChatCompletionAssistantMessageParamToolCallChatCompletionMessageFunctionToolCallParamFunction` The function that the model called. - `arguments: str` - `name: str` - `type: Literal["function"]` - `"function"` - `class MessageChatCompletionAssistantMessageParamToolCallChatCompletionMessageCustomToolCallParam: …` A call to a custom tool created by the model. - `id: str` - `custom: MessageChatCompletionAssistantMessageParamToolCallChatCompletionMessageCustomToolCallParamCustom` The custom tool that the model called. - `input: str` - `name: str` - `type: Literal["custom"]` - `"custom"` - `class MessageChatCompletionToolMessageParam: …` - `content: Union[str, Iterable[MessageChatCompletionToolMessageParamContentUnionMember1]]` - `str` - `Iterable[MessageChatCompletionToolMessageParamContentUnionMember1]` - `text: str` - `type: Literal["text"]` - `"text"` - `role: Literal["tool"]` - `"tool"` - `tool_call_id: str` - `class MessageChatCompletionFunctionMessageParam: …` - `content: Optional[str]` - `name: str` - `role: Literal["function"]` - `"function"` - `class MessageCustomChatCompletionMessageParam: …` Enables custom roles in the Chat Completion API. - `role: str` - `content: Optional[Union[str, SequenceNotStr[MessageCustomChatCompletionMessageParamContentUnionMember1]]]` - `str` - `SequenceNotStr[MessageCustomChatCompletionMessageParamContentUnionMember1]` - `class MessageCustomChatCompletionMessageParamContentUnionMember1ChatCompletionContentPartTextParam: …` Learn about [text inputs](https://platform.openai.com/docs/guides/text-generation). - `text: str` - `type: Literal["text"]` - `"text"` - `class MessageCustomChatCompletionMessageParamContentUnionMember1ChatCompletionContentPartImageParam: …` Learn about [image inputs](https://platform.openai.com/docs/guides/vision). - `image_url: MessageCustomChatCompletionMessageParamContentUnionMember1ChatCompletionContentPartImageParamImageURL` - `url: str` - `detail: Optional[Literal["auto", "low", "high"]]` - `"auto"` - `"low"` - `"high"` - `type: Literal["image_url"]` - `"image_url"` - `class MessageCustomChatCompletionMessageParamContentUnionMember1ChatCompletionContentPartInputAudioParam: …` Learn about [audio inputs](https://platform.openai.com/docs/guides/audio). - `input_audio: MessageCustomChatCompletionMessageParamContentUnionMember1ChatCompletionContentPartInputAudioParamInputAudio` - `data: str` - `format: Literal["wav", "mp3"]` - `"wav"` - `"mp3"` - `type: Literal["input_audio"]` - `"input_audio"` - `class MessageCustomChatCompletionMessageParamContentUnionMember1File: …` Learn about [file inputs](https://platform.openai.com/docs/guides/text) for text generation. - `file: MessageCustomChatCompletionMessageParamContentUnionMember1FileFile` - `file_data: Optional[str]` - `file_id: Optional[str]` - `filename: Optional[str]` - `type: Literal["file"]` - `"file"` - `class MessageCustomChatCompletionMessageParamContentUnionMember1ChatCompletionContentPartAudioParam: …` - `audio_url: MessageCustomChatCompletionMessageParamContentUnionMember1ChatCompletionContentPartAudioParamAudioURL` - `url: str` - `type: Literal["audio_url"]` - `"audio_url"` - `class MessageCustomChatCompletionMessageParamContentUnionMember1ChatCompletionContentPartVideoParam: …` - `type: Literal["video_url"]` - `"video_url"` - `video_url: MessageCustomChatCompletionMessageParamContentUnionMember1ChatCompletionContentPartVideoParamVideoURL` - `url: str` - `class MessageCustomChatCompletionMessageParamContentUnionMember1ChatCompletionContentPartRefusalParam: …` - `refusal: str` - `type: Literal["refusal"]` - `"refusal"` - `class MessageCustomChatCompletionMessageParamContentUnionMember1CustomChatCompletionContentSimpleImageParam: …` A simpler version of the param that only accepts a plain image_url. This is supported by OpenAI API, although it is not documented. Example: { "image_url": "https://example.com/image.jpg" } - `image_url: Optional[str]` - `uuid: Optional[str]` - `class MessageCustomChatCompletionMessageParamContentUnionMember1ChatCompletionContentPartImageEmbedsParam: …` - `type: Literal["image_embeds"]` - `"image_embeds"` - `image_embeds: Optional[Union[str, Dict[str, str], null]]` - `str` - `Dict[str, str]` - `uuid: Optional[str]` - `class MessageCustomChatCompletionMessageParamContentUnionMember1ChatCompletionContentPartAudioEmbedsParam: …` - `type: Literal["audio_embeds"]` - `"audio_embeds"` - `audio_embeds: Optional[Union[str, Dict[str, str], null]]` - `str` - `Dict[str, str]` - `uuid: Optional[str]` - `class MessageCustomChatCompletionMessageParamContentUnionMember1CustomChatCompletionContentSimpleAudioParam: …` A simpler version of the param that only accepts a plain audio_url. Example: { "audio_url": "https://example.com/audio.mp3" } - `audio_url: Optional[str]` - `class MessageCustomChatCompletionMessageParamContentUnionMember1CustomChatCompletionContentSimpleVideoParam: …` A simpler version of the param that only accepts a plain audio_url. Example: { "video_url": "https://example.com/video.mp4" } - `uuid: Optional[str]` - `video_url: Optional[str]` - `str` - `class MessageCustomChatCompletionMessageParamContentUnionMember1CustomThinkCompletionContentParam: …` A Think Completion Content Param that accepts a plain text and a boolean. Example: { "thinking": "I am thinking about the answer", "closed": True, "type": "thinking" } - `thinking: str` - `type: Literal["thinking"]` - `"thinking"` - `closed: Optional[bool]` - `name: Optional[str]` - `reasoning: Optional[str]` - `tool_call_id: Optional[str]` - `tool_calls: Optional[Iterable[MessageCustomChatCompletionMessageParamToolCall]]` - `id: str` - `function: MessageCustomChatCompletionMessageParamToolCallFunction` The function that the model called. - `arguments: str` - `name: str` - `type: Literal["function"]` - `"function"` - `tools: Optional[Iterable[MessageCustomChatCompletionMessageParamTool]]` - `function: MessageCustomChatCompletionMessageParamToolFunction` - `name: str` - `description: Optional[str]` - `parameters: Optional[Dict[str, object]]` - `strict: Optional[bool]` - `type: Literal["function"]` - `"function"` - `class MessageMessage: …` - `author: MessageMessageAuthor` - `role: Literal["user", "assistant", "system", 2 more]` The role of a message author (mirrors `chat::Role`). - `"user"` - `"assistant"` - `"system"` - `"developer"` - `"tool"` - `name: Optional[str]` - `channel: Optional[str]` - `content: Optional[Iterable[object]]` - `content_type: Optional[str]` - `recipient: Optional[str]` - `add_generation_prompt: Optional[bool]` If true, the generation prompt will be added to the chat template. This is a parameter used by chat template in tokenizer config of the model. - `add_special_tokens: Optional[bool]` If true, special tokens (e.g. BOS) will be added to the prompt on top of what is added by the chat template. For most models, the chat template takes care of adding the special tokens so this should be set to false (as is the default). - `allowed_token_ids: Optional[Iterable[int]]` - `bad_words: Optional[SequenceNotStr[str]]` - `cache_salt: Optional[str]` If specified, the prefix cache will be salted with the provided string to prevent an attacker to guess prompts in multi-user environments. The salt should be random, protected from access by 3rd parties, and long enough to be unpredictable (e.g., 43 characters base64-encoded, corresponding to 256 bit). - `chat_template: Optional[str]` A Jinja template to use for this conversion. As of transformers v4.44, default chat template is no longer allowed, so you must provide a chat template if the tokenizer does not define one. - `chat_template_kwargs: Optional[Dict[str, object]]` Additional keyword args to pass to the template renderer. Will be accessible by the chat template. - `continue_final_message: Optional[bool]` If this is set, the chat will be formatted so that the final message in the chat is open-ended, without any EOS tokens. The model will continue this message rather than starting a new one. This allows you to "prefill" part of the model's response for it. Cannot be used at the same time as `add_generation_prompt`. - `documents: Optional[Iterable[Dict[str, str]]]` A list of dicts representing documents that will be accessible to the model if it is performing RAG (retrieval-augmented generation). If the template does not support RAG, this argument will have no effect. We recommend that each document should be a dict containing "title" and "text" keys. - `echo: Optional[bool]` If true, the new message will be prepended with the last message if they belong to the same role. - `frequency_penalty: Optional[float]` - `ignore_eos: Optional[bool]` - `include_reasoning: Optional[bool]` - `include_stop_str_in_output: Optional[bool]` - `kv_transfer_params: Optional[Dict[str, object]]` KVTransfer parameters used for disaggregated serving. - `length_penalty: Optional[float]` - `logit_bias: Optional[Dict[str, float]]` - `logits_processors: Optional[SequenceNotStr[LogitsProcessor]]` A list of either qualified names of logits processors, or constructor objects, to apply when sampling. A constructor is a JSON object with a required 'qualname' field specifying the qualified name of the processor class/factory, and optional 'args' and 'kwargs' fields containing positional and keyword arguments. For example: {'qualname': 'my_module.MyLogitsProcessor', 'args': [1, 2], 'kwargs': {'param': 'value'}}. - `str` - `class LogitsProcessorLogitsProcessorConstructor: …` - `qualname: str` - `args: Optional[Iterable[object]]` - `kwargs: Optional[Dict[str, object]]` - `logprobs: Optional[bool]` - `max_completion_tokens: Optional[int]` - `max_tokens: Optional[int]` - `min_p: Optional[float]` - `min_tokens: Optional[int]` - `mm_processor_kwargs: Optional[Dict[str, object]]` Additional kwargs to pass to the HF processor. - `model: Optional[str]` - `n: Optional[int]` - `parallel_tool_calls: Optional[bool]` - `presence_penalty: Optional[float]` - `priority: Optional[int]` The priority of the request (lower means earlier handling; default: 0). Any priority other than 0 will raise an error if the served model does not use priority scheduling. - `prompt_logprobs: Optional[int]` - `reasoning_effort: Optional[Literal["low", "medium", "high"]]` - `"low"` - `"medium"` - `"high"` - `repetition_penalty: Optional[float]` - `request_id: Optional[str]` The request_id related to this request. If the caller does not set it, a random_uuid will be generated. This id is used through out the inference process and return in response. - `response_format: Optional[ResponseFormat]` - `class ResponseFormatResponseFormat: …` - `type: Literal["text", "json_object", "json_schema"]` - `"text"` - `"json_object"` - `"json_schema"` - `json_schema: Optional[ResponseFormatResponseFormatJsonSchema]` - `name: str` - `description: Optional[str]` - `schema: Optional[Dict[str, object]]` - `strict: Optional[bool]` - `class ResponseFormatStructuralTagResponseFormat: …` - `format: object` - `type: Literal["structural_tag"]` - `"structural_tag"` - `class ResponseFormatLegacyStructuralTagResponseFormat: …` - `structures: Iterable[ResponseFormatLegacyStructuralTagResponseFormatStructure]` - `begin: str` - `end: str` - `schema: Optional[Dict[str, object]]` - `triggers: SequenceNotStr[str]` - `type: Literal["structural_tag"]` - `"structural_tag"` - `return_token_ids: Optional[bool]` If specified, the result will include token IDs alongside the generated text. In streaming mode, prompt_token_ids is included only in the first chunk, and token_ids contains the delta tokens for each chunk. This is useful for debugging or when you need to map generated text back to input tokens. - `return_tokens_as_token_ids: Optional[bool]` If specified with 'logprobs', tokens are represented as strings of the form 'token_id:{token_id}' so that tokens that are not JSON-encodable can be identified. - `seed: Optional[int]` - `skip_special_tokens: Optional[bool]` - `spaces_between_special_tokens: Optional[bool]` - `stop: Optional[Union[str, SequenceNotStr[str], null]]` - `str` - `SequenceNotStr[str]` - `stop_token_ids: Optional[Iterable[int]]` - `stream: Optional[bool]` - `stream_options: Optional[StreamOptions]` - `continuous_usage_stats: Optional[bool]` - `include_usage: Optional[bool]` - `structured_outputs: Optional[StructuredOutputs]` Additional kwargs for structured outputs - `_backend: Optional[str]` - `_backend_was_auto: Optional[bool]` - `choice: Optional[SequenceNotStr[str]]` - `disable_additional_properties: Optional[bool]` - `disable_any_whitespace: Optional[bool]` - `disable_fallback: Optional[bool]` - `grammar: Optional[str]` - `json: Optional[Union[str, Dict[str, object], null]]` - `str` - `Dict[str, object]` - `json_object: Optional[bool]` - `regex: Optional[str]` - `structural_tag: Optional[str]` - `whitespace_pattern: Optional[str]` - `temperature: Optional[float]` - `tool_choice: Optional[ToolChoice]` - `Literal["none", "auto", "required"]` - `"none"` - `"auto"` - `"required"` - `class ToolChoiceChatCompletionNamedToolChoiceParam: …` - `function: ToolChoiceChatCompletionNamedToolChoiceParamFunction` - `name: str` - `type: Optional[Literal["function"]]` - `"function"` - `tools: Optional[Iterable[Tool]]` - `function: ToolFunction` - `name: str` - `description: Optional[str]` - `parameters: Optional[Dict[str, object]]` - `type: Optional[Literal["function"]]` - `"function"` - `top_k: Optional[int]` - `top_logprobs: Optional[int]` - `top_p: Optional[float]` - `truncate_prompt_tokens: Optional[int]` - `use_beam_search: Optional[bool]` - `user: Optional[str]` - `vllm_xargs: Optional[Dict[str, Union[str, float, SequenceNotStr[Union[str, float]]]]]` Additional request parameters with (list of) string or numeric values, used by custom extensions. - `str` - `float` - `SequenceNotStr[Union[str, float]]` - `str` - `float` ### Returns - `object` ### Example ```python import os from tzafon import Lightcone client = Lightcone( api_key=os.environ.get("TZAFON_API_KEY"), # This is the default and can be omitted ) response = client.chat.create_completion( messages=[{ "content": "string", "role": "developer", }], ) print(response) ```