Guides
Protocols and SDKs
Use OpenAI-compatible, Responses, and Anthropic Messages protocols, including streaming, tool calls, and migration.
Text generation supports three wire protocols; audio uses the STT and TTS endpoints below. Keep your existing SDK and change the base URL, API key, and model ID.
Endpoint matrix
| Protocol | Endpoint | Typical client |
|---|---|---|
| OpenAI Chat Completions | POST https://openapi.felo.ai/api/v1/chat/completions | OpenAI SDK, most OpenAI-compatible tools |
| OpenAI Responses | POST https://openapi.felo.ai/api/v1/responses | OpenAI SDK with Responses API features |
| Anthropic Messages | POST https://openapi.felo.ai/api/v1/messages | Anthropic SDK, Claude Code, Claude-native tools |
Base URLs
| Client | Base URL | Why |
|---|---|---|
| OpenAI SDK | https://openapi.felo.ai/api/v1 | The SDK appends /chat/completions or /responses |
| Anthropic SDK | https://openapi.felo.ai/api | The SDK appends /v1/messages; do not add /v1 yourself |
Both clients use your Felo API key as the SDK API key.
import OpenAI from "openai";
import Anthropic from "@anthropic-ai/sdk";
const openai = new OpenAI({
apiKey: process.env.FELO_API_KEY,
baseURL: "https://openapi.felo.ai/api/v1",
});
const anthropic = new Anthropic({
apiKey: process.env.FELO_API_KEY,
baseURL: "https://openapi.felo.ai/api",
});Choose a protocol
- Use Chat Completions when your tool or SDK expects the familiar
messagesarray andchoices[0].message.content. - Use Responses when you need OpenAI's Responses object,
input,instructions, oroutput_text. - Use Messages when you are using an Anthropic SDK or a Claude-native tool.
Check the model before assuming every protocol works. The catalog exposes supported_protocols, supported_parameters, and a recommended_protocol. recommended_protocol is a client recommendation, not a restriction; a model may still accept another protocol.
Streaming
Set stream: true to receive Server-Sent Events.
- Chat Completions emits OpenAI-style chat chunks.
- Responses emits Responses SSE events and ends with a completed response object.
- Messages emits Anthropic message stream events.
Read the event stream incrementally and handle the terminal event before closing the connection. A dropped connection is not the same as a completed response.
Tool calls and structured output
Pass tools in the protocol's native shape. Support varies by model, so check supported_parameters in the catalog before relying on tool calls, JSON mode, or structured output. A model can accept the field and still ignore an unsupported option.
Upload model files
Upload a file once with POST https://openapi.felo.ai/api/v1/files, then reference the returned felo_file_ ID in Messages or Responses requests. Chat Completions does not accept file IDs.
curl "https://openapi.felo.ai/api/v1/files" \
-H "Authorization: Bearer ${FELO_API_KEY}" \
-F "file=@./report.pdf"The body is multipart/form-data with a single file part. Let the client generate the multipart boundary, and do not add other parts such as purpose. Content blocks, limits, model support, and error codes are in File Uploads.
To store material as a LiveDoc knowledge resource, use the LiveDoc upload API. Model file uploads and LiveDoc resource uploads have their own identifiers and follow-up workflows.
Channel routing
All three endpoints accept X-Felo-Channel when you need to pin a provider. See Why does the same model have different prices? for the header rules and examples.
Migrate from an official API
- Change the base URL to the matching Felo URL.
- Replace the API key with
FELO_API_KEY. - Replace the model name with the public Felo model ID.
- Keep the rest of the request shape.
| Symptom | Likely cause |
|---|---|
| 404 on every request | Base URL already includes /v1, or the Anthropic base URL has /v1 added manually |
| 401 | The Felo key is missing or the client is still sending the old key |
400 model error | The model ID is not public or does not support the chosen endpoint |
| Messages request rejected | max_tokens is required by the Messages protocol |
| Tool call ignored | The model does not advertise that capability |
Speech-to-text / Text-to-speech
Choose a published model with model_kind=audio_transcription (STT) or audio_speech (TTS). Use its public ID and check the selected channel. The catalog exposes speech_spec for the default TTS channel; voices and formats can differ across channels.
curl --fail 'https://openapi.felo.ai/api/platform/model-catalog?locale=en&fmt=full' \
| jq '.data.models[] | select(.model_kind == "audio_transcription" or .model_kind == "audio_speech") | {id, model_kind, speech_spec, channels}'STT
POST /api/v1/audio/transcriptions
Send model and file as multipart/form-data. The file must be a complete mono PCM WAV, at most 25,000,000 bytes; channel-specific sample-rate and duration limits also apply. Optional fields: language (two lowercase letters, e.g. en) and response_format=json (the only format, also the default). Let curl generate the boundary. URLs, file IDs, prompt, timestamps and stream are not supported.
curl --fail-with-body 'https://openapi.felo.ai/api/v1/audio/transcriptions' \
-H "Authorization: Bearer $FELO_API_KEY" \
--form-string 'model=YOUR_STT_MODEL_ID' \
--form-string 'response_format=json' \
-F 'file=@./sample.wav;type=audio/wav'The synchronous JSON response contains text; usage is optional and can report seconds or tokens. usage.cost is upstream cost, not your final Felo charge. There is no task to poll.
TTS
POST /api/v1/audio/speech
Send JSON with model and non-blank input (up to 4096 Unicode code points). response_format defaults to pcm, but MP3-only channels require an explicit mp3. Only speed=1 is currently supported; omit instructions and stream.
You can omit voice or supply a voice ID. The upstream model decides whether a voice is required and which IDs it accepts. Catalog voices are examples.
curl --fail 'https://openapi.felo.ai/api/v1/audio/speech' \
-H "Authorization: Bearer $FELO_API_KEY" \
-H 'Content-Type: application/json' \
--output speech.mp3 \
--data '{"model":"YOUR_TTS_MODEL_ID","input":"Hello!","voice":"SUPPORTED_VOICE","response_format":"mp3"}'Success returns audio bytes: audio/mpeg for MP3 or audio/pcm for raw PCM, not WAV, JSON or SSE. Check the HTTP status and complete transfer before playback; --fail keeps HTTP error bodies out of the audio file. A broken connection can leave a partial file: discard it. Raw PCM playback requires the channel's audio parameters; do not guess them.
Billing depends on the published channel. STT may use input audio seconds (input_audio_second) or token rates. TTS may use input characters (input_character), UTF-8 bytes (input_utf8_byte), input text and output audio tokens (prompt and output_audio_token), or output audio seconds (output_audio_second). For character rates, check speech_billing_unit; utf16_code_unit and unicode_code_point count emoji differently. configured_rates uses frozen rates and verified usage; upstream_cost uses verified provider cost with the published markup and discount. Reservation is an estimate, not a spending cap. Finalization may be asynchronous, and missing evidence does not mean zero cost.
STT accepts X-Felo-Channel; omitting it uses default routing. A single explicit channel disables fallback. TTS selects channels automatically and does not support choosing one in the request.
When configured, the server may switch to another eligible channel after a submission-stage upstream rejection or transport error. It does not switch for HTTP 400, 413 or 422, certain responses with acceptance or generation evidence, or after a successful response has begun. A transport failure can leave the upstream outcome unknown. Do not automatically retry from the client after a timeout or disconnect, including SDK retries; retain X-Request-Id and any X-Generation-Id for reconciliation. Console Playground does not yet support these audio calls.
Related
Need help?
- Contact Support for API, billing, and account questions.
- Chat with Felo developers on Discord.
- Check out our changelog.
- Need volume pricing or procurement help? Contact Sales.
- Building with an LLM? Read llms.txt.