Completion
Create chat completions with any provider
any_llm.completion()
any_llm.completion()def completion(
model: str,
messages: list[dict[str, Any] | ChatCompletionMessage],
*,
provider: str | LLMProvider | None = None,
tools: list[dict[str, Any] | Callable[..., Any]] | None = None,
tool_choice: str | dict[str, Any] | None = None,
temperature: float | None = None,
top_p: float | None = None,
max_tokens: int | None = None,
response_format: dict[str, Any] | type | None = None,
stream: bool | None = None,
n: int | None = None,
stop: str | list[str] | None = None,
presence_penalty: float | None = None,
frequency_penalty: float | None = None,
seed: int | None = None,
api_key: str | None = None,
api_base: str | None = None,
user: str | None = None,
session_label: str | None = None,
parallel_tool_calls: bool | None = None,
logprobs: bool | None = None,
top_logprobs: int | None = None,
logit_bias: dict[str, float] | None = None,
stream_options: dict[str, Any] | None = None,
max_completion_tokens: int | None = None,
reasoning_effort: Literal['none', 'minimal', 'low', 'medium', 'high', 'xhigh', 'max', 'auto'] | None = "auto",
client_args: dict[str, Any] | None = None,
**kwargs: Any,
) -> ChatCompletion | Iterator[ChatCompletionChunk]any_llm.acompletion()
any_llm.acompletion()Parameters
Parameter
Type
Default
Description
Return Value
Usage
Basic completion
Streaming
Async
Structured output
Tool calling
Last updated