{
  "openapi": "3.1.0",
  "info": {
    "title": "Function API",
    "version": "1.2",
    "summary": "Speech to polished text, and speech to text.",
    "description": "Function's dictation as an API. Send a recording, or stream one, and get back polished text (function/dictate-1.2) or every word as it was said (function/transcribe-1.2). Docs: https://functionvoice.ai/docs/api",
    "contact": {
      "name": "Function",
      "email": "jakemny@gmail.com",
      "url": "https://functionvoice.ai/support"
    },
    "termsOfService": "https://functionvoice.ai/support"
  },
  "externalDocs": {
    "description": "Function API docs",
    "url": "https://functionvoice.ai/docs/api"
  },
  "servers": [
    {
      "url": "https://functionvoice.ai/api/v1"
    }
  ],
  "tags": [
    {
      "name": "Transcriptions",
      "description": "Speech in, text out."
    },
    {
      "name": "Models",
      "description": "What the API offers, and what each costs."
    },
    {
      "name": "Keys",
      "description": "The calling key's spend and limits."
    }
  ],
  "paths": {
    "/audio/transcriptions": {
      "post": {
        "operationId": "createTranscription",
        "summary": "Transcribe a recording",
        "description": "Send a recording and get its text back: polished with function/dictate-1.2, or as it was said with function/transcribe-1.2. As JSON with the audio in base64, or as multipart with the file. Up to 10 minutes and 24 MB.",
        "tags": [
          "Transcriptions"
        ],
        "externalDocs": {
          "url": "https://functionvoice.ai/docs/api/transcriptions"
        },
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/TranscriptionRequest"
              }
            },
            "multipart/form-data": {
              "schema": {
                "$ref": "#/components/schemas/TranscriptionMultipartRequest"
              },
              "encoding": {
                "keyterms[]": {
                  "style": "form",
                  "explode": true
                }
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "The text.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Transcription"
                }
              }
            },
            "headers": {
              "X-Function-Generation-Id": {
                "description": "The request's id, as the dashboard lists it. Quote it when you report a problem.",
                "schema": {
                  "type": "string"
                }
              }
            }
          },
          "400": {
            "description": "invalid_request: A field is missing or wrong. The message says which. unsupported_audio_format: Not WAV, M4A or PCM.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "401": {
            "description": "missing_api_key: No key in the Authorization header. invalid_api_key: The key is wrong or revoked. expired_api_key: The key is past its expiry.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "402": {
            "description": "payment_required: Add a payment method in the dashboard.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "403": {
            "description": "ip_not_allowed: The request came from outside the key's IP allowlist. forbidden: The key isn't allowed to use this model. spend_limit: The key reached its spending limit. `metadata.limit_source` says which: `key_lifetime`, `key_week` or `key_month`.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "413": {
            "description": "payload_too_large: Over 10 minutes or 24 MB of audio.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "429": {
            "description": "rate_limited: Over 120 requests a minute for the key. Wait for `Retry-After`.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "500": {
            "description": "internal_error: Something went wrong on our side. Try again.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "502": {
            "description": "transcription_failed: The audio couldn't be transcribed this time. Try again. You aren't charged.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "503": {
            "description": "unavailable: The service is briefly unavailable. Try again after `Retry-After`.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          }
        },
        "security": [
          {
            "bearer": []
          }
        ]
      },
      "get": {
        "operationId": "streamTranscription",
        "summary": "Stream a recording over a WebSocket",
        "description": "Open a WebSocket to wss://functionvoice.ai/api/v1/audio/transcriptions (Upgrade: websocket), send audio while the person speaks as binary 16-bit little-endian mono PCM, then send {\"type\": \"input_audio_buffer.commit\"}. The text arrives in a transcript.text.done event and the socket closes. Events: session.created, session.update, session.updated, input_audio_buffer.append, input_audio_buffer.commit, input_audio_buffer.committed, transcript.text.done, error. A refusal before the socket opens is an HTTP error.",
        "tags": [
          "Transcriptions"
        ],
        "externalDocs": {
          "url": "https://functionvoice.ai/docs/api/streaming"
        },
        "parameters": [
          {
            "name": "model",
            "in": "query",
            "required": true,
            "description": "`function/dictate-1.2` for polished text, `function/transcribe-1.2` for every word as it was said. `function/dictate` and `function/transcribe` name the latest version.",
            "schema": {
              "type": "string",
              "enum": [
                "function/dictate-1.2",
                "function/transcribe-1.2",
                "function/dictate",
                "function/transcribe"
              ]
            }
          },
          {
            "name": "language",
            "in": "query",
            "required": false,
            "description": "The language spoken, as an ISO-639-1 code such as `en` or `es`. English if left out. Dictate writes in the language that was spoken.",
            "schema": {
              "type": "string",
              "examples": [
                "en"
              ]
            }
          },
          {
            "name": "sample_rate",
            "in": "query",
            "required": false,
            "description": "For `pcm` only: its sample rate in Hz.",
            "schema": {
              "type": "integer",
              "minimum": 8000,
              "maximum": 48000,
              "default": 16000
            }
          },
          {
            "name": "keyterms",
            "in": "query",
            "required": false,
            "description": "Names and terms to spell exactly as given: people, products, jargon. Up to 1,000, each up to 100 characters. Repeat the parameter once per term.",
            "schema": {
              "type": "array",
              "maxItems": 1000,
              "items": {
                "type": "string",
                "maxLength": 100
              }
            },
            "style": "form",
            "explode": true
          },
          {
            "name": "Upgrade",
            "in": "header",
            "required": true,
            "description": "`websocket`.",
            "schema": {
              "type": "string",
              "enum": [
                "websocket"
              ]
            }
          }
        ],
        "responses": {
          "101": {
            "description": "Switching to the WebSocket protocol."
          },
          "400": {
            "description": "invalid_request: A field is missing or wrong. The message says which.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "401": {
            "description": "missing_api_key: No key in the Authorization header. invalid_api_key: The key is wrong or revoked. expired_api_key: The key is past its expiry.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "402": {
            "description": "payment_required: Add a payment method in the dashboard.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "403": {
            "description": "ip_not_allowed: The request came from outside the key's IP allowlist. forbidden: The key isn't allowed to use this model. spend_limit: The key reached its spending limit. `metadata.limit_source` says which: `key_lifetime`, `key_week` or `key_month`.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "429": {
            "description": "rate_limited: Over 120 requests a minute for the key. Wait for `Retry-After`.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "503": {
            "description": "unavailable: The service is briefly unavailable. Try again after `Retry-After`.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          }
        },
        "security": [
          {
            "bearer": []
          }
        ],
        "servers": [
          {
            "url": "wss://functionvoice.ai/api/v1",
            "description": "The WebSocket stream."
          }
        ]
      }
    },
    "/models": {
      "get": {
        "operationId": "listModels",
        "summary": "List the models",
        "description": "Every model, with its price. Needs no key.",
        "tags": [
          "Models"
        ],
        "externalDocs": {
          "url": "https://functionvoice.ai/docs/api/models"
        },
        "parameters": [
          {
            "name": "output_modalities",
            "in": "query",
            "required": false,
            "description": "Only models with these outputs, comma-separated. `transcription` or `all` matches every model.",
            "schema": {
              "type": "string",
              "examples": [
                "transcription"
              ]
            }
          }
        ],
        "responses": {
          "200": {
            "description": "The models.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "data",
                    "total_count"
                  ],
                  "properties": {
                    "data": {
                      "type": "array",
                      "items": {
                        "$ref": "#/components/schemas/Model"
                      }
                    },
                    "total_count": {
                      "type": "integer"
                    }
                  }
                }
              }
            }
          }
        },
        "security": []
      }
    },
    "/models/{id}": {
      "get": {
        "operationId": "getModel",
        "summary": "Get a model",
        "description": "One model, with its price. Needs no key. The id has a slash, as in /models/function/dictate-1.2.",
        "tags": [
          "Models"
        ],
        "externalDocs": {
          "url": "https://functionvoice.ai/docs/api/models"
        },
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "required": true,
            "description": "The model's id.",
            "schema": {
              "type": "string",
              "enum": [
                "function/dictate-1.2",
                "function/transcribe-1.2",
                "function/dictate",
                "function/transcribe"
              ]
            }
          }
        ],
        "responses": {
          "200": {
            "description": "The model.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "data"
                  ],
                  "properties": {
                    "data": {
                      "$ref": "#/components/schemas/Model"
                    }
                  }
                }
              }
            }
          },
          "404": {
            "description": "not_found: No such endpoint or model.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          }
        },
        "security": []
      }
    },
    "/key": {
      "get": {
        "operationId": "getKey",
        "summary": "Get the key's spend and limits",
        "description": "The calling key's name, what it has spent, its spending limit and what is left of it, its permissions, expiry and rate limit.",
        "tags": [
          "Keys"
        ],
        "externalDocs": {
          "url": "https://functionvoice.ai/docs/api/key"
        },
        "responses": {
          "200": {
            "description": "The key.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/KeyInfo"
                }
              }
            }
          },
          "401": {
            "description": "missing_api_key: No key in the Authorization header. invalid_api_key: The key is wrong or revoked. expired_api_key: The key is past its expiry.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "403": {
            "description": "ip_not_allowed: The request came from outside the key's IP allowlist.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "429": {
            "description": "rate_limited: Over 120 requests a minute for the key. Wait for `Retry-After`.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          }
        },
        "security": [
          {
            "bearer": []
          }
        ]
      }
    }
  },
  "components": {
    "securitySchemes": {
      "bearer": {
        "type": "http",
        "scheme": "bearer",
        "description": "Your API key, from the dashboard: Authorization: Bearer fn_live_…"
      }
    },
    "schemas": {
      "TranscriptionRequest": {
        "type": "object",
        "required": [
          "model",
          "input_audio"
        ],
        "properties": {
          "model": {
            "type": "string",
            "enum": [
              "function/dictate-1.2",
              "function/transcribe-1.2",
              "function/dictate",
              "function/transcribe"
            ],
            "description": "`function/dictate-1.2` for polished text, `function/transcribe-1.2` for every word as it was said. `function/dictate` and `function/transcribe` name the latest version."
          },
          "input_audio": {
            "type": "object",
            "required": [
              "data",
              "format"
            ],
            "description": "The recording.",
            "properties": {
              "data": {
                "type": "string",
                "contentMediaType": "application/octet-stream",
                "description": "The audio as base64: the raw bytes, not a data URI."
              },
              "format": {
                "type": "string",
                "enum": [
                  "wav",
                  "m4a",
                  "pcm"
                ],
                "description": "`wav`, `m4a` (AAC) or `pcm` (raw 16-bit little-endian mono)."
              }
            }
          },
          "language": {
            "type": "string",
            "examples": [
              "en"
            ],
            "description": "The language spoken, as an ISO-639-1 code such as `en` or `es`. English if left out. Dictate writes in the language that was spoken."
          },
          "keyterms": {
            "type": "array",
            "maxItems": 1000,
            "items": {
              "type": "string",
              "maxLength": 100
            },
            "description": "Names and terms to spell exactly as given: people, products, jargon. Up to 1,000, each up to 100 characters."
          },
          "sample_rate": {
            "type": "integer",
            "minimum": 8000,
            "maximum": 48000,
            "default": 16000,
            "description": "For `pcm` only: its sample rate in Hz."
          },
          "response_format": {
            "type": "string",
            "enum": [
              "json",
              "verbose_json"
            ],
            "default": "json",
            "description": "`verbose_json` adds `task`, `language` and `duration` to the answer."
          }
        }
      },
      "TranscriptionMultipartRequest": {
        "type": "object",
        "required": [
          "model",
          "file"
        ],
        "properties": {
          "model": {
            "type": "string",
            "enum": [
              "function/dictate-1.2",
              "function/transcribe-1.2",
              "function/dictate",
              "function/transcribe"
            ],
            "description": "`function/dictate-1.2` for polished text, `function/transcribe-1.2` for every word as it was said. `function/dictate` and `function/transcribe` name the latest version."
          },
          "file": {
            "type": "string",
            "format": "binary",
            "description": "The recording. Its format is read from the file."
          },
          "language": {
            "type": "string",
            "examples": [
              "en"
            ],
            "description": "The language spoken, as an ISO-639-1 code such as `en` or `es`. English if left out. Dictate writes in the language that was spoken."
          },
          "keyterms[]": {
            "type": "array",
            "maxItems": 1000,
            "items": {
              "type": "string",
              "maxLength": 100
            },
            "description": "Names and terms to spell exactly as given: people, products, jargon. Up to 1,000, each up to 100 characters. Repeat the field once per term."
          },
          "sample_rate": {
            "type": "integer",
            "minimum": 8000,
            "maximum": 48000,
            "default": 16000,
            "description": "For `pcm` only: its sample rate in Hz."
          },
          "response_format": {
            "type": "string",
            "enum": [
              "json",
              "verbose_json"
            ],
            "default": "json",
            "description": "`verbose_json` adds `task`, `language` and `duration` to the answer."
          }
        }
      },
      "Transcription": {
        "type": "object",
        "required": [
          "text",
          "usage"
        ],
        "properties": {
          "text": {
            "type": "string",
            "description": "The text: polished for Dictate, as said for Transcribe. Empty when nothing was said."
          },
          "usage": {
            "$ref": "#/components/schemas/Usage",
            "description": "What the request used and cost."
          },
          "task": {
            "type": "string",
            "enum": [
              "transcribe"
            ],
            "description": "With `verbose_json` only."
          },
          "language": {
            "type": [
              "string",
              "null"
            ],
            "description": "With `verbose_json` only: the language heard, when known."
          },
          "duration": {
            "type": "number",
            "description": "With `verbose_json` only: the recording's length, in seconds."
          }
        }
      },
      "Usage": {
        "type": "object",
        "required": [
          "seconds",
          "cost"
        ],
        "description": "What the request used and cost.",
        "properties": {
          "seconds": {
            "type": "number",
            "description": "The recording's length, in seconds."
          },
          "cost": {
            "type": "number",
            "description": "What this request cost, in dollars: at least 10 seconds at its model's hourly price."
          }
        }
      },
      "Model": {
        "type": "object",
        "required": [
          "id",
          "name",
          "description",
          "pricing"
        ],
        "properties": {
          "id": {
            "type": "string",
            "description": "The model's id, to send as `model`."
          },
          "canonical_slug": {
            "type": "string",
            "description": "The same id."
          },
          "name": {
            "type": "string",
            "description": "Its display name."
          },
          "created": {
            "type": "integer",
            "description": "When it was added, in Unix seconds."
          },
          "description": {
            "type": "string",
            "description": "What it returns."
          },
          "architecture": {
            "type": "object",
            "description": "Audio in, text out: `input_modalities` is `[\"audio\"]`, `output_modalities` is `[\"transcription\"]`."
          },
          "pricing": {
            "type": "object",
            "description": "Prices in dollars, as strings.",
            "properties": {
              "audio": {
                "type": "string",
                "description": "Per second of audio."
              },
              "audio_per_hour": {
                "type": "string",
                "description": "Per hour of audio."
              },
              "minimum_seconds": {
                "type": "string",
                "description": "The least a request is billed for."
              }
            }
          },
          "supported_parameters": {
            "type": "array",
            "items": {
              "type": "string"
            },
            "description": "The optional request fields it reads."
          },
          "endpoints": {
            "type": "array",
            "items": {
              "type": "string"
            },
            "description": "Where to send it."
          }
        }
      },
      "KeyInfo": {
        "type": "object",
        "required": [
          "data"
        ],
        "properties": {
          "data": {
            "type": "object",
            "properties": {
              "label": {
                "type": "string",
                "description": "The key's name."
              },
              "usage": {
                "type": "number",
                "description": "Dollars spent, in all."
              },
              "usage_daily": {
                "type": "number",
                "description": "Dollars spent today (UTC)."
              },
              "usage_weekly": {
                "type": "number",
                "description": "Dollars spent this week (UTC, from Monday)."
              },
              "usage_monthly": {
                "type": "number",
                "description": "Dollars spent this month (UTC)."
              },
              "limit": {
                "type": [
                  "number",
                  "null"
                ],
                "description": "The spending limit in dollars, or null for none."
              },
              "limit_remaining": {
                "type": [
                  "number",
                  "null"
                ],
                "description": "What is left of it."
              },
              "limit_reset": {
                "type": [
                  "string",
                  "null"
                ],
                "enum": [
                  "weekly",
                  "monthly",
                  null
                ],
                "description": "When the limit starts over. Null for a lifetime limit, or none."
              },
              "expires_at": {
                "type": [
                  "string",
                  "null"
                ],
                "format": "date-time",
                "description": "When the key stops working, or null."
              },
              "permissions": {
                "type": "array",
                "items": {
                  "type": "string",
                  "enum": [
                    "dictate",
                    "transcribe"
                  ]
                },
                "description": "The models it may use."
              },
              "is_free_tier": {
                "type": "boolean",
                "description": "Always false."
              },
              "is_management_key": {
                "type": "boolean",
                "description": "Always false."
              },
              "rate_limit": {
                "type": "object",
                "description": "`{\"requests\": 120, \"interval\": \"1m\"}`."
              }
            }
          }
        }
      },
      "Error": {
        "type": "object",
        "required": [
          "error"
        ],
        "properties": {
          "error": {
            "type": "object",
            "required": [
              "code",
              "message",
              "metadata"
            ],
            "properties": {
              "code": {
                "type": "integer",
                "description": "The HTTP status."
              },
              "message": {
                "type": "string",
                "description": "What went wrong, to read."
              },
              "metadata": {
                "type": "object",
                "required": [
                  "error_type"
                ],
                "additionalProperties": true,
                "properties": {
                  "error_type": {
                    "type": "string",
                    "enum": [
                      "invalid_request",
                      "unsupported_audio_format",
                      "missing_api_key",
                      "invalid_api_key",
                      "expired_api_key",
                      "payment_required",
                      "forbidden",
                      "ip_not_allowed",
                      "spend_limit",
                      "not_found",
                      "method_not_allowed",
                      "timeout",
                      "payload_too_large",
                      "rate_limited",
                      "internal_error",
                      "transcription_failed",
                      "unavailable"
                    ],
                    "description": "What went wrong, to act on."
                  },
                  "limit_source": {
                    "type": "string",
                    "enum": [
                      "key_lifetime",
                      "key_week",
                      "key_month"
                    ],
                    "description": "With `spend_limit` only."
                  }
                }
              }
            }
          }
        }
      }
    }
  }
}