Function's dictation as an API. Send speech, get back text: polished the way Function's keyboard writes it, or every word as it was said.
curl https://functionvoice.ai/api/v1/audio/transcriptions \
-H "Authorization: Bearer $FUNCTION_API_KEY" \
-F model=function/dictate-1.2 \
-F file=@recording.m4a{
"text": "Can you send the deck to Priya by Friday?",
"usage": { "seconds": 3.82, "cost": 0.0020833333 }
}Base URL. https://functionvoice.ai/api/v1
Try every parameter without writing code in the dashboard's playground. Its Overview page has a prompt to paste into your coding agent that integrates the API for you.
Send your key as a bearer token on every request:
Authorization: Bearer fn_live_…
Create keys in the dashboard. A key is shown once, when it is made: we keep only a fingerprint of it, so it can't be shown again or recovered. Keep keys on your server. Never ship one in an app or a web page, and never put one in a URL. A revoked key stops working at once.
Each key can carry its own rules, all enforced by the API:
403 forbidden.401 expired_api_key.403 ip_not_allowed.403 spend_limit, with metadata.limit_source naming which (key_lifetime, key_week or key_month).The method is the model. Both take the same request and give the same answer.
| Model | What it returns |
|---|---|
function/dictate-1.2 | Speech to polished text, as Function's keyboard types it: fillers and false starts gone, self-corrections resolved, lists and paragraphs laid out, in the speaker's own voice. It formats for what you're writing, keeps every detail, and never answers or carries out what was said. |
function/transcribe-1.2 | Speech to text: every word as it was said, punctuated, with the names and terms you send spelled right. |
function/dictate and function/transcribe always name the latest version. Pin the version to keep the same behavior.
GET /api/v1/models lists them (?output_modalities=transcription filters), each with its price: pricing.audio per second and pricing.audio_per_hour, in dollars.
POST /api/v1/audio/transcriptions, as multipart/form-data with the file, or as JSON with the audio in base64.
curl https://functionvoice.ai/api/v1/audio/transcriptions \
-H "Authorization: Bearer $FUNCTION_API_KEY" \
-F model=function/transcribe-1.2 \
-F file=@recording.wav \
-F language=en \
-F 'keyterms[]=Priya' -F 'keyterms[]=Q3 roadmap'
curl https://functionvoice.ai/api/v1/audio/transcriptions \
-H "Authorization: Bearer $FUNCTION_API_KEY" \
-H "Content-Type: application/json" \
-d '{
"model": "function/dictate-1.2",
"input_audio": { "data": "'"$(base64 < recording.wav)"'", "format": "wav" },
"language": "en",
"keyterms": ["Priya", "Q3 roadmap"]
}'
import os, requests
with open("recording.m4a", "rb") as audio:
answer = requests.post(
"https://functionvoice.ai/api/v1/audio/transcriptions",
headers={"Authorization": f"Bearer {os.environ['FUNCTION_API_KEY']}"},
data={"model": "function/dictate-1.2", "language": "en"},
files={"file": audio},
).json()
print(answer["text"])
import { readFile } from "node:fs/promises";
const body = new FormData();
body.append("model", "function/dictate-1.2");
body.append("file", new Blob([await readFile("recording.m4a")]), "recording.m4a");
const answer = await fetch("https://functionvoice.ai/api/v1/audio/transcriptions", {
method: "POST",
headers: { Authorization: `Bearer ${process.env.FUNCTION_API_KEY}` },
body,
}).then((response) => response.json());
console.log(answer.text);
| Field | Type | What it is |
|---|---|---|
model | string, required | function/dictate-1.2 or function/transcribe-1.2. |
file | file (multipart) | The recording. Its format is read from the file itself. |
input_audio | object (JSON) | data, the audio as base64 (raw bytes, not a data URI), and format: wav, m4a or pcm. |
language | string | The language spoken, as an ISO-639-1 code such as en or es. English if you leave it out. Dictate keeps the language that was spoken. |
keyterms | array of strings | Names and terms to spell exactly as given: people, products, jargon. Up to 1,000, each up to 100 characters. In multipart, repeat keyterms[]. |
sample_rate | integer | For pcm only: its rate in Hz, 8000 to 48000. 16000 if you leave it out. |
response_format | string | json (the default) or verbose_json. |
prompt, temperature, timestamp_granularities, provider, user and session_id are accepted and ignored, so a client written for this common shape works unchanged.
sample_rate says otherwise.Up to 10 minutes and 24 MB a request. MP3, FLAC, Ogg and WebM are refused with unsupported_audio_format.
{
"text": "Can you send the deck to Priya by Friday?",
"usage": { "seconds": 3.82, "cost": 0.0020833333 }
}
| Field | What it is |
|---|---|
text | The text: polished for Dictate, as said for Transcribe. Empty when nothing was said. |
usage.seconds | The recording's length. |
usage.cost | What this request cost, in dollars (see Pricing). |
With "response_format": "verbose_json", the answer also has task, language (the language heard, when known) and duration.
Each answer's X-Function-Generation-Id header names the request. It is the id in the dashboard's request list; quote it when you report a problem.
Stream audio while the user speaks, and get the text a moment after they stop. Open a WebSocket to the same path, with the model in the URL and your key in the Authorization header:
wss://functionvoice.ai/api/v1/audio/transcriptions?model=function/dictate-1.2&language=en
The URL also takes sample_rate and repeated keyterms. A client that can't set headers on a WebSocket, as in a browser, can send the key as two subprotocols instead, function-api and bearer. followed by the key; the server answers with function-api. Never put a key in a page you ship to others.
Then:
session.created.session.update with keyterms, language or sample_rate. The server answers session.updated.sample_rate says), or input_audio_buffer.append events with the PCM as base64. Every 100 to 250 ms is a good pace.input_audio_buffer.commit. The server sends input_audio_buffer.committed, then transcript.text.done with the text and the usage, and closes the socket.→ {"type": "session.update", "session": {"keyterms": ["Priya"], "sample_rate": 16000}}
← {"type": "session.updated", "session": {"id": "gen-…", "model": "function/dictate-1.2", "input_audio_format": "pcm16", "sample_rate": 16000, …}}
→ (binary PCM) (binary PCM) …
→ {"type": "input_audio_buffer.commit"}
← {"type": "input_audio_buffer.committed", "audio_seconds": 3.82}
← {"type": "transcript.text.done", "text": "Can you send the deck to Priya by Friday?", "usage": {"seconds": 3.82, "cost": 0.0020833333}}
import WebSocket from "ws";
const socket = new WebSocket("wss://functionvoice.ai/api/v1/audio/transcriptions?model=function/dictate-1.2", {
headers: { Authorization: `Bearer ${process.env.FUNCTION_API_KEY}` },
});
socket.on("open", () => {
microphone.on("data", (pcm) => socket.send(pcm)); // 16-bit mono, 16 kHz
microphone.on("end", () => socket.send(JSON.stringify({ type: "input_audio_buffer.commit" })));
});
socket.on("message", (data) => {
const event = JSON.parse(data.toString());
if (event.type === "transcript.text.done") console.log(event.text);
if (event.type === "error") console.error(event.error.message);
});
import asyncio, json, os, websockets
async def dictate(chunks):
async with websockets.connect(
"wss://functionvoice.ai/api/v1/audio/transcriptions?model=function/dictate-1.2",
additional_headers={"Authorization": f"Bearer {os.environ['FUNCTION_API_KEY']}"},
) as socket:
async for chunk in chunks: # bytes of 16-bit mono PCM at 16 kHz
await socket.send(chunk)
await socket.send(json.dumps({"type": "input_audio_buffer.commit"}))
async for message in socket:
event = json.loads(message)
if event["type"] == "transcript.text.done":
return event["text"]
if event["type"] == "error":
raise RuntimeError(event["error"]["message"])
A stream checks the key and its rules, the model and the payment method before it opens: a refusal is an HTTP error, as for a POST. After it opens, a problem is an error event in the same shape as an error's body. One that ends the stream is followed by a close. A stream with no message for 20 seconds before its commit is closed with timeout. A stream is billed like a file: its audio, at least 10 seconds.
An error has the HTTP status, a message to read, and a type to act on:
{
"error": {
"code": 403,
"message": "This API key has reached its spending limit of $25.00 this month (UTC).",
"metadata": { "error_type": "spend_limit", "limit_source": "key_month" }
}
}
| Status | error_type | Meaning |
|---|---|---|
| 400 | invalid_request | A field is missing or wrong. The message says which. |
| 400 | unsupported_audio_format | Not WAV, M4A or PCM. |
| 401 | missing_api_key, invalid_api_key | No key, or one that's wrong or revoked. |
| 401 | expired_api_key | The key is past its expiry. |
| 402 | payment_required | Add a payment method in the dashboard. |
| 403 | forbidden | The key isn't allowed to use this model. |
| 403 | ip_not_allowed | The request came from outside the key's IP allowlist. |
| 403 | spend_limit | The key reached its spending limit. metadata.limit_source says which. |
| 404 | not_found | No such endpoint or model. |
| 405 | method_not_allowed | The wrong method for the endpoint. |
| 408 | timeout | A stream went quiet before its commit. |
| 413 | payload_too_large | Over 10 minutes or 24 MB. |
| 429 | rate_limited | Over 120 requests a minute for the key. Wait for Retry-After. |
| 500 | internal_error | Something went wrong on our side. Try again. |
| 502 | transcription_failed | The audio couldn't be transcribed this time. Try again. You aren't charged. |
| 503 | unavailable | The service is briefly unavailable. Try again after Retry-After. |
| Model | Per hour of audio |
|---|---|
function/dictate-1.2 | $0.75 |
function/transcribe-1.2 | $0.75 |
Your data. We don't keep your audio or the text. The dashboard keeps each request's time, length, status and cost, for your usage.
GET /api/v1/key: the key's name, what it has spent in dollars (in all, today, this week and this month, in UTC), its spending limit and what is left of it, its permissions and expiry, and its rate limit.
{
"data": {
"label": "Production",
"usage": 4.21, "usage_daily": 0.12, "usage_weekly": 0.95, "usage_monthly": 4.21,
"limit": 25, "limit_remaining": 20.79, "limit_reset": "monthly",
"expires_at": null, "permissions": ["dictate", "transcribe"],
"is_free_tier": false, "is_management_key": false,
"rate_limit": { "requests": 120, "interval": "1m" }
}
}