FG API Documentation
Real-time voice AI for business: speech recognition, dialogue, and synthesis in three HTTP calls. Base URL: http://localhost:4100/v1 (beta).
1. Get an API key
Sign up and create a key in the console. A key like fg-… is shown only once — save it.
2. Your first audio — in one command
curl http://localhost:4100/v1/audio/speech \ -H "Authorization: Bearer $FG_API_KEY" \ -H "Content-Type: application/json" \ -d '{ "model": "fg-voice-1", "voice": "sergei", "input": "Sir, the platform is connected." }' --output hello.mp3 && open hello.mp3
3. The full voice loop
The assistant is a pipeline of three calls. Each step is its own endpoint, with your code in between:
- Transcribe: the user’s audio →
POST /v1/audio/transcriptions→ text; - Think: text →
POST /v1/chat/completionswithstream: true→ a reply, sentence by sentence; - Speak: each sentence →
POST /v1/audio/speech→ mp3, played as it arrives.
Authentication
Every request carries an Authorization: Bearer fg-… header. Keys are created and revoked in the console; we store only a fingerprint of the key.
Model
GET/v1/models
fg-voice-1 — the flagship voice model for business assistants: real-time dialogue, sentence-by-sentence streaming.
{
"object": "list",
"data": [{ "id": "fg-voice-1", "object": "model", "owned_by": "fg-ai" }]
}Chat completions
POST/v1/chat/completions
Chat with the model. The format matches OpenAI: the same messages array, the same chat.completion response, the same chunked streaming. By default the model is tuned for speech: short phrases, no markdown.
| Parameter | Type | Description |
|---|---|---|
| messagesrequired | array | The conversation: {role: "system"|"user"|"assistant", content: "…"}. Your own system replaces the assistant’s default persona. |
| modeloptional | string | fg-voice-1 (default). |
| streamoptional | boolean | SSE stream. Deltas arrive sentence by sentence — send each straight to speech synthesis. |
| max_tokensoptional | integer | 1–4096, default 1024. |
curl http://localhost:4100/v1/chat/completions \ -H "Authorization: Bearer $FG_API_KEY" \ -H "Content-Type: application/json" \ -d '{ "model": "fg-voice-1", "stream": true, "messages": [ { "role": "user", "content": "Summarize this week's sales" } ] }'
Response (stream: true)
# each data: is a whole sentence, ready for speech data: {"object":"chat.completion.chunk", "choices":[{"delta":{"content":"Summary ready. "}}]} data: {"object":"chat.completion.chunk", "choices":[{"delta":{"content":"Revenue is up eight percent. "}}]} data: [DONE]
Speech synthesis
POST/v1/audio/speech
Text → audio/mpeg audio (mp3, 44.1 kHz). Latency is a fraction of a second — suitable for real-time replies.
| Parameter | Type | Description |
|---|---|---|
| inputrequired | string | Text up to 4096 characters. The language is detected automatically (ru/en). |
| voiceoptional | string | A voice name (sergei — default) or a voice ID from the catalog. |
| modeloptional | string | fg-voice-1. |
Speech recognition
POST/v1/audio/transcriptions
Audio → text. multipart/form-data with a file field: webm/opus, mp3, wav, m4a. A built-in filter drops noise and recognition “hallucinations” — silence returns an empty text, and the assistant just keeps listening.
curl http://localhost:4100/v1/audio/transcriptions \ -H "Authorization: Bearer $FG_API_KEY" \ -F file=@question.webm \ -F model=fg-voice-1 # → {"text": "What's the revenue this week?"}
| Parameter | Type | Description |
|---|---|---|
| filerequired | file | Audio file up to 32 MB. |
| languageoptional | string | Language code (ru by default, en, …) — a hint that makes recognition faster and sharper. |
Voices
A voice is chosen by name. In beta, sergei is available (Russian male, default) — the name library is growing. Advanced: pass the ID of any voice from our catalog (700+ voices).
Migrate from OpenAI
The API is compatible with OpenAI’s format. In the official SDK you change two lines — the base URL and the key:
import OpenAI from 'openai'; // before: new OpenAI({ apiKey: 'sk-…' }) const client = new OpenAI({ baseURL: 'http://localhost:4100/v1', apiKey: process.env.FG_API_KEY, // fg-… }); // the rest of your code is unchanged: const chat = await client.chat.completions.create({ model: 'fg-voice-1', messages: [{ role: 'user', content: 'Hello!' }], });
| OpenAI | FG |
|---|---|
gpt-4o, gpt-4o-mini… | fg-voice-1 |
voice: "alloy" / "verse" | voice: "sergei" |
whisper-1 | fg-voice-1 (you can leave the model field unchanged — it’s ignored) |
| Realtime API (WebRTC/WS) | A cascade of three HTTP calls + an opener line (see Quickstart) — comparable UX without WebRTC |
Errors & limits
Error format matches OpenAI: an HTTP status + JSON with error.type and error.code.
| Status | code | What to do |
|---|---|---|
| 401 | missing_api_key / invalid_api_key | Check the Authorization: Bearer fg-… header and that the key isn’t revoked. |
| 400 | missing_input, unknown_voice, … | The message names the specific field. |
| 429 | daily_quota_exceeded | Beta: 2000 requests per day per account. The counter resets at midnight UTC. |
| 5xx | api_error | Retry with exponential backoff. |