{
  "openapi": "3.1.0",
  "info": {
    "title": "Local Language Lab Company API",
    "version": "1.1.0",
    "description": "Server-to-server company keys. Prepaid USD billing: speech $1.20/1,000 UTF-16 characters, text $0.20/reply, audio $1.50/minute, video $3/minute including audio. Calls billed per second; checkout availability shown in API & billing. Operator pilots retain their allowances. POST retries are not idempotent and may charge again. See https://locallanguagelab.com/developers."
  },
  "servers": [
    {
      "url": "https://locallanguagelab.com/api/v1/company",
      "description": "Production"
    }
  ],
  "security": [
    {
      "CompanyKey": []
    }
  ],
  "paths": {
    "/voices": {
      "get": {
        "operationId": "listVoices",
        "summary": "List approved speech voices (up to 100)",
        "description": "Required key scope: catalog:read.",
        "responses": {
          "200": {
            "description": "Success",
            "headers": {
              "X-Request-Id": {
                "description": "Server correlation ID",
                "schema": {
                  "type": "string",
                  "format": "uuid"
                }
              },
              "Cache-Control": {
                "schema": {
                  "const": "no-store"
                }
              }
            },
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "data": {
                      "type": "array",
                      "items": {
                        "$ref": "#/components/schemas/Voice"
                      }
                    }
                  },
                  "required": [
                    "data"
                  ]
                }
              }
            }
          },
          "default": {
            "description": "Error. 400 invalid request; 401 invalid key; 403 scope; 404 resource; 413 size; 415 content type; 422 unsupported mode; 429 rate/quota/call limit; 502 provider; 503 unavailable.",
            "headers": {
              "X-Request-Id": {
                "description": "Server correlation ID",
                "schema": {
                  "type": "string",
                  "format": "uuid"
                }
              },
              "Cache-Control": {
                "schema": {
                  "const": "no-store"
                }
              },
              "Retry-After": {
                "description": "60 on minute rate limits only",
                "schema": {
                  "type": "string"
                }
              }
            },
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          }
        }
      }
    },
    "/agents": {
      "get": {
        "operationId": "listAgents",
        "summary": "List assigned active agents (up to 100)",
        "description": "Required key scope: catalog:read.",
        "responses": {
          "200": {
            "description": "Success",
            "headers": {
              "X-Request-Id": {
                "description": "Server correlation ID",
                "schema": {
                  "type": "string",
                  "format": "uuid"
                }
              },
              "Cache-Control": {
                "schema": {
                  "const": "no-store"
                }
              }
            },
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "data": {
                      "type": "array",
                      "items": {
                        "$ref": "#/components/schemas/Agent"
                      }
                    }
                  },
                  "required": [
                    "data"
                  ]
                }
              }
            }
          },
          "default": {
            "description": "Error. 400 invalid request; 401 invalid key; 403 scope; 404 resource; 413 size; 415 content type; 422 unsupported mode; 429 rate/quota/call limit; 502 provider; 503 unavailable.",
            "headers": {
              "X-Request-Id": {
                "description": "Server correlation ID",
                "schema": {
                  "type": "string",
                  "format": "uuid"
                }
              },
              "Cache-Control": {
                "schema": {
                  "const": "no-store"
                }
              },
              "Retry-After": {
                "description": "60 on minute rate limits only",
                "schema": {
                  "type": "string"
                }
              }
            },
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          }
        }
      }
    },
    "/speech": {
      "post": {
        "operationId": "generateSpeech",
        "summary": "Generate speech using an approved voice",
        "description": "Required key scope: speech:write.",
        "responses": {
          "200": {
            "description": "Success",
            "headers": {
              "X-Request-Id": {
                "description": "Server correlation ID",
                "schema": {
                  "type": "string",
                  "format": "uuid"
                }
              },
              "Cache-Control": {
                "schema": {
                  "const": "no-store"
                }
              }
            },
            "content": {
              "audio/wav": {
                "schema": {
                  "type": "string",
                  "format": "binary"
                }
              },
              "audio/mpeg": {
                "schema": {
                  "type": "string",
                  "format": "binary"
                }
              }
            }
          },
          "default": {
            "description": "Error. 400 invalid request; 401 invalid key; 403 scope; 404 resource; 413 size; 415 content type; 422 unsupported mode; 429 rate/quota/call limit; 502 provider; 503 unavailable.",
            "headers": {
              "X-Request-Id": {
                "description": "Server correlation ID",
                "schema": {
                  "type": "string",
                  "format": "uuid"
                }
              },
              "Cache-Control": {
                "schema": {
                  "const": "no-store"
                }
              },
              "Retry-After": {
                "description": "60 on minute rate limits only",
                "schema": {
                  "type": "string"
                }
              }
            },
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "402": {
            "description": "Insufficient prepaid balance"
          }
        },
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/SpeechInput"
              }
            }
          }
        }
      }
    },
    "/agents/{agent_id}/messages": {
      "post": {
        "operationId": "createMessage",
        "summary": "Get a knowledge-grounded text reply",
        "description": "Required key scope: messages:write.",
        "responses": {
          "200": {
            "description": "Success",
            "headers": {
              "X-Request-Id": {
                "description": "Server correlation ID",
                "schema": {
                  "type": "string",
                  "format": "uuid"
                }
              },
              "Cache-Control": {
                "schema": {
                  "const": "no-store"
                }
              }
            },
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/MessageReply"
                }
              }
            }
          },
          "default": {
            "description": "Error. 400 invalid request; 401 invalid key; 403 scope; 404 resource; 413 size; 415 content type; 422 unsupported mode; 429 rate/quota/call limit; 502 provider; 503 unavailable.",
            "headers": {
              "X-Request-Id": {
                "description": "Server correlation ID",
                "schema": {
                  "type": "string",
                  "format": "uuid"
                }
              },
              "Cache-Control": {
                "schema": {
                  "const": "no-store"
                }
              },
              "Retry-After": {
                "description": "60 on minute rate limits only",
                "schema": {
                  "type": "string"
                }
              }
            },
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "402": {
            "description": "Insufficient prepaid balance"
          }
        },
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/MessagesInput"
              }
            }
          }
        },
        "parameters": [
          {
            "in": "path",
            "name": "agent_id",
            "required": true,
            "schema": {
              "type": "string",
              "format": "uuid"
            }
          }
        ]
      }
    },
    "/agents/{agent_id}/sessions": {
      "post": {
        "operationId": "createSession",
        "summary": "Issue single-use live audio/video admission",
        "description": "Required key scope: sessions:write.",
        "responses": {
          "201": {
            "description": "Success",
            "headers": {
              "X-Request-Id": {
                "description": "Server correlation ID",
                "schema": {
                  "type": "string",
                  "format": "uuid"
                }
              },
              "Cache-Control": {
                "schema": {
                  "const": "no-store"
                }
              }
            },
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Session"
                }
              }
            }
          },
          "default": {
            "description": "Error. 400 invalid request; 401 invalid key; 403 scope; 404 resource; 413 size; 415 content type; 422 unsupported mode; 429 rate/quota/call limit; 502 provider; 503 unavailable.",
            "headers": {
              "X-Request-Id": {
                "description": "Server correlation ID",
                "schema": {
                  "type": "string",
                  "format": "uuid"
                }
              },
              "Cache-Control": {
                "schema": {
                  "const": "no-store"
                }
              },
              "Retry-After": {
                "description": "60 on minute rate limits only",
                "schema": {
                  "type": "string"
                }
              }
            },
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "402": {
            "description": "Insufficient prepaid balance"
          }
        },
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/SessionInput"
              }
            }
          }
        },
        "parameters": [
          {
            "in": "path",
            "name": "agent_id",
            "required": true,
            "schema": {
              "type": "string",
              "format": "uuid"
            }
          }
        ]
      }
    },
    "/usage": {
      "get": {
        "operationId": "getUsage",
        "summary": "Read monthly admitted attempts and limits",
        "description": "Required key scope: usage:read.",
        "responses": {
          "200": {
            "description": "Success",
            "headers": {
              "X-Request-Id": {
                "description": "Server correlation ID",
                "schema": {
                  "type": "string",
                  "format": "uuid"
                }
              },
              "Cache-Control": {
                "schema": {
                  "const": "no-store"
                }
              }
            },
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Usage"
                }
              }
            }
          },
          "default": {
            "description": "Error. 400 invalid request; 401 invalid key; 403 scope; 404 resource; 413 size; 415 content type; 422 unsupported mode; 429 rate/quota/call limit; 502 provider; 503 unavailable.",
            "headers": {
              "X-Request-Id": {
                "description": "Server correlation ID",
                "schema": {
                  "type": "string",
                  "format": "uuid"
                }
              },
              "Cache-Control": {
                "schema": {
                  "const": "no-store"
                }
              },
              "Retry-After": {
                "description": "60 on minute rate limits only",
                "schema": {
                  "type": "string"
                }
              }
            },
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          }
        }
      }
    }
  },
  "components": {
    "securitySchemes": {
      "CompanyKey": {
        "type": "apiKey",
        "in": "header",
        "name": "X-API-Key"
      }
    },
    "schemas": {
      "Error": {
        "type": "object",
        "properties": {
          "error": {
            "type": "object",
            "properties": {
              "code": {
                "type": "string"
              },
              "message": {
                "type": "string"
              }
            },
            "required": [
              "code",
              "message"
            ]
          },
          "request_id": {
            "type": "string",
            "format": "uuid"
          }
        },
        "required": [
          "error",
          "request_id"
        ]
      },
      "Voice": {
        "type": "object",
        "properties": {
          "id": {
            "type": "string",
            "format": "uuid"
          },
          "name": {
            "type": "string"
          },
          "description": {
            "type": "string"
          },
          "language_codes": {
            "type": "array",
            "items": {
              "type": "string"
            }
          }
        },
        "required": [
          "id",
          "name",
          "description",
          "language_codes"
        ]
      },
      "Agent": {
        "type": "object",
        "properties": {
          "id": {
            "type": "string",
            "format": "uuid"
          },
          "name": {
            "type": "string"
          },
          "company": {
            "anyOf": [
              {
                "type": "string"
              },
              {
                "type": "null"
              }
            ]
          },
          "agent_type": {
            "enum": [
              "text",
              "audio",
              "video"
            ]
          },
          "language_code": {
            "type": "string"
          },
          "audio_profile_id": {
            "anyOf": [
              {
                "type": "string",
                "format": "uuid"
              },
              {
                "type": "null"
              }
            ]
          },
          "video_profile_id": {
            "anyOf": [
              {
                "type": "string",
                "format": "uuid"
              },
              {
                "type": "null"
              }
            ]
          },
          "video_enabled": {
            "type": "boolean"
          },
          "image_url": {
            "type": [
              "string",
              "null"
            ],
            "format": "uri",
            "description": "Public portrait for audio agents or selected Anam presenter thumbnail for video agents. Use this image in your website or app."
          }
        },
        "required": [
          "id",
          "name",
          "company",
          "agent_type",
          "language_code",
          "audio_profile_id",
          "video_profile_id",
          "video_enabled",
          "image_url"
        ]
      },
      "SpeechInput": {
        "type": "object",
        "properties": {
          "voice_id": {
            "type": "string",
            "format": "uuid"
          },
          "language": {
            "enum": [
              "bislama",
              "twi",
              "ga",
              "ewe",
              "en",
              "fr",
              "zh",
              "es",
              "pt",
              "ar",
              "hi"
            ]
          },
          "text": {
            "type": "string",
            "minLength": 1,
            "maxLength": 4000
          }
        },
        "required": [
          "voice_id",
          "language",
          "text"
        ],
        "additionalProperties": false
      },
      "MessagesInput": {
        "type": "object",
        "properties": {
          "messages": {
            "type": "array",
            "minItems": 1,
            "maxItems": 20,
            "description": "Last message must have user role. Last 12 messages form model context.",
            "items": {
              "type": "object",
              "properties": {
                "role": {
                  "enum": [
                    "user",
                    "assistant"
                  ]
                },
                "content": {
                  "type": "string",
                  "minLength": 1,
                  "maxLength": 4000
                }
              },
              "required": [
                "role",
                "content"
              ]
            }
          }
        },
        "required": [
          "messages"
        ],
        "additionalProperties": false
      },
      "MessageReply": {
        "type": "object",
        "properties": {
          "agent_id": {
            "type": "string",
            "format": "uuid"
          },
          "reply": {
            "type": "string"
          }
        },
        "required": [
          "agent_id",
          "reply"
        ]
      },
      "SessionInput": {
        "type": "object",
        "properties": {
          "mode": {
            "enum": [
              "audio",
              "video"
            ]
          },
          "transcript_consent": {
            "type": "boolean"
          }
        },
        "required": [
          "mode",
          "transcript_consent"
        ],
        "additionalProperties": false
      },
      "Session": {
        "type": "object",
        "properties": {
          "agent_id": {
            "type": "string",
            "format": "uuid"
          },
          "mode": {
            "enum": [
              "audio",
              "video"
            ]
          },
          "expires_in": {
            "type": "integer",
            "const": 60
          },
          "max_duration_seconds": {
            "type": "integer",
            "minimum": 1
          },
          "audio": {
            "type": "object",
            "properties": {
              "url": {
                "type": "string",
                "format": "uri"
              },
              "start": {
                "type": "object",
                "properties": {
                  "type": {
                    "const": "start"
                  },
                  "grant": {
                    "type": "string",
                    "pattern": "^[a-f0-9]{64}$"
                  },
                  "transcript_consent": {
                    "type": "boolean"
                  }
                },
                "required": [
                  "type",
                  "grant",
                  "transcript_consent"
                ]
              },
              "input_format": {
                "type": "object",
                "properties": {
                  "encoding": {
                    "const": "pcm_s16le"
                  },
                  "sample_rate": {
                    "const": 24000
                  },
                  "channels": {
                    "const": 1
                  }
                },
                "required": [
                  "encoding",
                  "sample_rate",
                  "channels"
                ]
              }
            },
            "required": [
              "url",
              "start",
              "input_format"
            ]
          },
          "video": {
            "anyOf": [
              {
                "type": "object",
                "properties": {
                  "credential": {
                    "type": "string"
                  },
                  "engine_path": {
                    "const": "/api/anam-session/v1/engine/session"
                  }
                },
                "required": [
                  "credential",
                  "engine_path"
                ]
              },
              {
                "type": "null"
              }
            ]
          }
        },
        "required": [
          "agent_id",
          "mode",
          "expires_in",
          "max_duration_seconds",
          "audio",
          "video"
        ]
      },
      "Units": {
        "type": "object",
        "properties": {
          "speech_characters": {
            "type": "integer",
            "minimum": 0
          },
          "messages": {
            "type": "integer",
            "minimum": 0
          },
          "sessions": {
            "type": "integer",
            "minimum": 0
          }
        },
        "required": [
          "speech_characters",
          "messages",
          "sessions"
        ]
      },
      "Usage": {
        "type": "object",
        "properties": {
          "month": {
            "type": "string",
            "format": "date"
          },
          "used": {
            "$ref": "#/components/schemas/Units"
          },
          "limits": {
            "$ref": "#/components/schemas/Units",
            "description": "Operator pilot quotas. Prepaid accounts use wallet admission instead."
          },
          "wallet": {
            "$ref": "#/components/schemas/Wallet"
          }
        },
        "required": [
          "month",
          "used",
          "limits",
          "wallet"
        ]
      },
      "Wallet": {
        "type": "object",
        "properties": {
          "currency": {
            "type": "string",
            "const": "usd"
          },
          "available_micro": {
            "type": "integer",
            "description": "Available balance in millionths of a US dollar; can be negative after refunds of spent credit."
          },
          "prepaid": {
            "type": "boolean",
            "description": "True for self-service wallets; false for operator-managed pilot allowances."
          },
          "blocked": {
            "type": "boolean"
          }
        },
        "required": [
          "currency",
          "available_micro",
          "prepaid",
          "blocked"
        ]
      }
    }
  }
}
