Documentation

API Reference

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

string
Required

The 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 objects
Required

A list of messages describing the conversation so far. Each object must have a role ('system', 'user', or 'assistant') and content (string).

role

string
Required

The role of the message author (e.g., 'system', 'user', 'assistant', 'tool').

content

string or array of objects
Required

The content of the message. For multimodal models, this can be an array of text and image_url objects.

name

string

Optional. The name of the author of this message. May be used to provide a user identifier for the message.

tool_calls

array of objects

Optional. The tool calls generated by the model, if any.

tool_call_id

string

Required if role is 'tool'. The ID of the tool call.

temperature

number

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.

Default: 1

top_p

number

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.

Default: 1

n

integer

How 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

boolean

Whether 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 strings

Up to 4 sequences where the API will stop generating further tokens.

Default: null

max_tokens

integer

The 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

number

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.

Default: 0

frequency_penalty

number

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.

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

string

A 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 objects

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. See Tool Calling documentation.

tool_choice

string or object

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 { "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

object

An 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.

Was this page helpful?