image-musicText to Audio

Create Chat Completion

post

Creates a chat completion for the provided messages. Supports streaming, function calling, vision, multimodal inputs, and reasoning tokens for supported models (OpenAI o-series, Grok, Gemini thinking, Anthropic). Compatible with OpenAI SDK.

Authorizations
AuthorizationstringRequired

FastRouter API Key. Get yours at https://fastrouter.ai

Format: Authorization: Bearer YOUR_API_KEY

Body
modelstringRequired

Model ID in format 'provider/model'. Examples: openai/gpt-5.1, google/gemini-3-pro-preview, anthropic/claude-4.5-sonnet

Example: anthropic/claude-4.5-sonnet
temperaturenumber · max: 2Optional

Controls randomness in responses. Lower values (0-0.7) make output more focused and deterministic. Higher values (0.8-2) make output more creative and random.

Default: 1Example: 0.7
max_tokensinteger · min: 1Optional

Maximum number of tokens to generate in the completion. Limits the length of the response.

Example: 1000
top_pnumber · max: 1Optional

Nucleus sampling parameter. Alternative to temperature. Lower values make output more focused.

Default: 1Example: 0.9
frequency_penaltynumber · min: -2 · max: 2Optional

Penalizes repeated tokens based on frequency. Positive values reduce repetition.

Default: 0Example: 0
presence_penaltynumber · min: -2 · max: 2Optional

Penalizes tokens that have appeared. Positive values encourage new topics.

Default: 0Example: 0
streambooleanOptional

Enable streaming responses for real-time output. When true, responses are sent as Server-Sent Events (SSE).

Default: falseExample: true
stopone ofOptional

Stop sequences where the model will stop generating. Can be a string or array of strings.

Example: ["\\n","END"]
stringOptional
or
string[]Optional
toolsarrayOptional

Array of tool/function definitions

aspectRatiostring · enumOptional

Image aspect ratio for Nano Banana (google/gemini-2.5-flash-image). Supported ratios: 1:1, 2:3, 3:2, 3:4, 4:3, 4:5, 5:4, 9:16, 16:9, 21:9

Example: 3:2Possible values:
promptstringOptional

Natural-language description for audio generation (ace-step/prompt-to-audio). Describe the audio, music, or ambient sound to generate.

Example: A lofi hiphop song with a chill vibe about a sunny day on the boardwalk.
durationinteger · min: 1Optional

Duration of the audio clip in seconds for text-to-audio generation (ace-step/prompt-to-audio). Optional parameter.

Example: 5
Responses
post
/chat/completions

Retrieve Audio Generation Results

post

Retrieves asynchronous audio generation results from ace-step/prompt-to-audio model.

Two-Step Process:

Step 1: Call /chat/completions with model ace-step/prompt-to-audio and your prompt

Step 2: Take the response_url from that response and poll this endpoint until audio is ready

Poll with the response_url until the audio generation is complete and download link is available.

Authorizations
AuthorizationstringRequired

FastRouter API Key. Get yours at https://fastrouter.ai

Format: Authorization: Bearer YOUR_API_KEY

Body
urlstring · uriRequired

The response_url returned from the initial /chat/completions request. This URL is used to poll for the audio generation status and retrieve the final result.

Example: https://queue.fal.run/fal-ai/ace-step/requests/123abcdef
modelstring · enumRequired

Must be 'ace-step/prompt-to-audio'

Example: ace-step/prompt-to-audioPossible values:
Responses
post
/getPromptToAudioResponse

Last updated