Documentation
Parameters
Supported parameters for A4F API requests, primarily for the /v1/chat/completions
endpoint.
A4F aims for compatibility with the OpenAI API specification. The following parameters are commonly supported and are generally passed through to the underlying model provider. Support for less common or highly specific parameters may vary depending on the chosen provider and model.
Request Body Parameters
model
stringThe ID of the model to use for the completion. For A4F, this must include the provider prefix, e.g., provider-X/model-name
. See the Models page for available models and Provider Routing for details.
messages
array of objectsA list of messages describing the conversation so far. Each object must have a role ('system', 'user', or 'assistant') and content (string).
role
stringThe role of the message author (e.g., 'system', 'user', 'assistant', 'tool').
content
string or array of objectsThe content of the message. For multimodal models, this can be an array of text and image_url objects.
name
stringOptional. The name of the author of this message. May be used to provide a user identifier for the message.
tool_calls
array of objectsOptional. The tool calls generated by the model, if any.
tool_call_id
stringRequired if role is 'tool'. The ID of the tool call.
temperature
numberWhat 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.
Default: 1
top_p
numberAn 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.
Default: 1
n
integerHow many chat completion choices to generate for each input message. Note that A4F passes this to the provider, but not all providers may support n > 1.
Default: 1
stream
booleanWhether to stream back partial progress. If set, tokens will be sent as data-only server-sent events as they become available, with the stream terminated by a data: [DONE]
message. See Streaming for more details.
Default: false
stop
string or array of stringsUp to 4 sequences where the API will stop generating further tokens.
Default: null
max_tokens
integerThe maximum number of tokens to generate in the chat completion. The total length of input tokens and generated tokens is limited by the model's context length.
presence_penalty
numberNumber 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.
Default: 0
frequency_penalty
numberNumber 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.
Default: 0
logit_bias
map (string to integer)Modify the likelihood of specified tokens appearing in the completion. Accepts a JSON object that maps tokens (specified by their token ID) to an associated bias value from -100 to 100.
Default: null
user
stringA unique identifier representing your end-user, which can help A4F and underlying providers to monitor and detect abuse. A4F does not use this for any other purpose beyond forwarding it if the provider supports it.
tools
array of objectsA 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. See Tool Calling documentation.
tool_choice
string or objectControls 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 { "type": "function", "function": { "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. See Tool Calling documentation.
response_format
objectAn object specifying the format that the model must output. Currently, the only supported type is json_object
. Setting to { "type": "json_object" }
enables JSON mode, which guarantees the message a 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.
Provider Variability
Was this page helpful?