{
  "openapi": "3.1.0",
  "info": {
    "title": "Puppetry Developer API Beta",
    "description": "Live beta endpoints for Puppetry Voice API access and hosted audio uploads. The beta currently supports listing Puppetry voices, generating speech from text, and creating signed upload URLs for existing audio.",
    "version": "2026-05-11",
    "contact": {
      "name": "Puppetry Support",
      "url": "https://www.puppetry.com",
      "email": "support@puppetry.com"
    },
    "termsOfService": "https://www.puppetry.com/tos",
    "license": {
      "name": "Proprietary"
    }
  },
  "servers": [
    {
      "url": "https://www.puppetry.com",
      "description": "Production"
    }
  ],
  "security": [
    {
      "developerApiKey": []
    }
  ],
  "paths": {
    "/api/v1/voices/puppetry": {
      "get": {
        "operationId": "listPuppetryVoices",
        "summary": "List Puppetry voices",
        "description": "Returns the public Puppetry voice catalog available to Developer API keys with the voices:read scope.",
        "tags": ["Voices"],
        "security": [
          {
            "developerApiKey": []
          }
        ],
        "responses": {
          "200": {
            "description": "Public Puppetry voices",
            "headers": {
              "X-RateLimit-Limit": {
                "$ref": "#/components/headers/RateLimitLimit"
              },
              "X-RateLimit-Remaining": {
                "$ref": "#/components/headers/RateLimitRemaining"
              },
              "X-RateLimit-Reset": {
                "$ref": "#/components/headers/RateLimitReset"
              }
            },
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/VoiceListResponse"
                }
              }
            }
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "403": {
            "$ref": "#/components/responses/Forbidden"
          },
          "429": {
            "$ref": "#/components/responses/RateLimited"
          }
        }
      }
    },
    "/api/v1/tts/puppetry": {
      "post": {
        "operationId": "createPuppetrySpeech",
        "summary": "Generate speech with a Puppetry voice",
        "description": "Creates a hosted WAV audio file from text using a public Puppetry voice. Requires the tts:create scope.",
        "tags": ["Text to Speech"],
        "security": [
          {
            "developerApiKey": []
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/TtsRequest"
              },
              "examples": {
                "speech": {
                  "summary": "Generate speech",
                  "value": {
                    "voice_id": "puppetry-af_bella",
                    "text": "Hello from Puppetry.",
                    "speed": 1
                  }
                }
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Generated audio",
            "headers": {
              "X-RateLimit-Limit": {
                "$ref": "#/components/headers/RateLimitLimit"
              },
              "X-RateLimit-Remaining": {
                "$ref": "#/components/headers/RateLimitRemaining"
              },
              "X-RateLimit-Reset": {
                "$ref": "#/components/headers/RateLimitReset"
              }
            },
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/TtsResponse"
                }
              }
            }
          },
          "400": {
            "$ref": "#/components/responses/InvalidRequest"
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "403": {
            "$ref": "#/components/responses/Forbidden"
          },
          "404": {
            "description": "Unknown Puppetry voice",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                },
                "examples": {
                  "voiceNotFound": {
                    "value": {
                      "error": "voice_not_found",
                      "message": "Unknown Puppetry voice"
                    }
                  }
                }
              }
            }
          },
          "429": {
            "$ref": "#/components/responses/RateLimited"
          },
          "502": {
            "$ref": "#/components/responses/UpstreamFailure"
          },
          "503": {
            "$ref": "#/components/responses/TemporarilyUnavailable"
          }
        }
      }
    },
    "/api/v1/uploads/audio-url": {
      "post": {
        "operationId": "createHostedAudioUploadUrl",
        "summary": "Create a signed hosted audio upload URL",
        "description": "Creates a short-lived signed PUT URL for existing audio and a short-lived read URL for the uploaded asset. Requires the uploads:create scope.",
        "tags": ["Audio Uploads"],
        "security": [
          {
            "developerApiKey": []
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/AudioUploadRequest"
              },
              "examples": {
                "audioUpload": {
                  "summary": "Create upload URL",
                  "value": {
                    "mime_type": "audio/mpeg",
                    "content_length": 1048576
                  }
                }
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Signed upload and read URLs",
            "headers": {
              "X-RateLimit-Limit": {
                "$ref": "#/components/headers/RateLimitLimit"
              },
              "X-RateLimit-Remaining": {
                "$ref": "#/components/headers/RateLimitRemaining"
              },
              "X-RateLimit-Reset": {
                "$ref": "#/components/headers/RateLimitReset"
              }
            },
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/AudioUploadUrlResponse"
                }
              }
            }
          },
          "400": {
            "$ref": "#/components/responses/InvalidRequest"
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "403": {
            "$ref": "#/components/responses/Forbidden"
          },
          "413": {
            "description": "Audio file exceeds the 50MB upload limit",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                },
                "examples": {
                  "fileTooLarge": {
                    "value": {
                      "error": "file_too_large",
                      "message": "Audio uploads are limited to 50MB",
                      "details": {
                        "max_file_bytes": 52428800
                      }
                    }
                  }
                }
              }
            }
          },
          "429": {
            "$ref": "#/components/responses/RateLimited"
          },
          "502": {
            "$ref": "#/components/responses/UpstreamFailure"
          }
        }
      }
    }
  },
  "components": {
    "securitySchemes": {
      "developerApiKey": {
        "type": "http",
        "scheme": "bearer",
        "bearerFormat": "Puppetry API key",
        "description": "Use the Authorization header with a live Puppetry API key: Bearer pk_live_..."
      }
    },
    "headers": {
      "RateLimitLimit": {
        "description": "Requests allowed in the current one-minute window.",
        "schema": {
          "type": "integer",
          "example": 10
        }
      },
      "RateLimitRemaining": {
        "description": "Requests remaining in the current one-minute window.",
        "schema": {
          "type": "integer",
          "example": 9
        }
      },
      "RateLimitReset": {
        "description": "Unix timestamp, in seconds, when the current rate-limit window resets.",
        "schema": {
          "type": "integer",
          "example": 1778520000
        }
      },
      "RetryAfter": {
        "description": "Seconds to wait before retrying after a rate-limit response.",
        "schema": {
          "type": "integer",
          "example": 30
        }
      }
    },
    "responses": {
      "InvalidRequest": {
        "description": "Invalid request body or unsupported input",
        "content": {
          "application/json": {
            "schema": {
              "$ref": "#/components/schemas/ErrorResponse"
            }
          }
        }
      },
      "Unauthorized": {
        "description": "Missing, malformed, invalid, or revoked API key",
        "content": {
          "application/json": {
            "schema": {
              "$ref": "#/components/schemas/ErrorResponse"
            },
            "examples": {
              "unauthorized": {
                "value": {
                  "error": "unauthorized",
                  "message": "Missing or invalid Authorization header. Use: Bearer pk_live_..."
                }
              }
            }
          }
        }
      },
      "Forbidden": {
        "description": "The API key does not include the required endpoint scope.",
        "content": {
          "application/json": {
            "schema": {
              "$ref": "#/components/schemas/ErrorResponse"
            },
            "examples": {
              "forbidden": {
                "value": {
                  "error": "forbidden",
                  "message": "This API key does not have the required scope"
                }
              }
            }
          }
        }
      },
      "RateLimited": {
        "description": "Rate limit or monthly beta quota exceeded",
        "headers": {
          "X-RateLimit-Limit": {
            "$ref": "#/components/headers/RateLimitLimit"
          },
          "X-RateLimit-Remaining": {
            "$ref": "#/components/headers/RateLimitRemaining"
          },
          "X-RateLimit-Reset": {
            "$ref": "#/components/headers/RateLimitReset"
          },
          "Retry-After": {
            "$ref": "#/components/headers/RetryAfter"
          }
        },
        "content": {
          "application/json": {
            "schema": {
              "$ref": "#/components/schemas/ErrorResponse"
            },
            "examples": {
              "rateLimited": {
                "value": {
                  "error": "rate_limited",
                  "message": "Developer API beta limit exceeded: 10 requests per minute."
                }
              },
              "voiceCharacterLimit": {
                "value": {
                  "error": "voice_character_limit_exceeded",
                  "message": "Monthly Puppetry Voice character limit exceeded"
                }
              }
            }
          }
        }
      },
      "UpstreamFailure": {
        "description": "Puppetry could not create the requested asset.",
        "content": {
          "application/json": {
            "schema": {
              "$ref": "#/components/schemas/ErrorResponse"
            }
          }
        }
      },
      "TemporarilyUnavailable": {
        "description": "A beta quota or job counter is temporarily unavailable.",
        "content": {
          "application/json": {
            "schema": {
              "$ref": "#/components/schemas/ErrorResponse"
            }
          }
        }
      }
    },
    "schemas": {
      "ErrorResponse": {
        "type": "object",
        "required": ["error", "message"],
        "properties": {
          "error": {
            "type": "string",
            "examples": ["invalid_request", "unauthorized", "rate_limited"]
          },
          "message": {
            "type": "string"
          },
          "details": {
            "description": "Endpoint-specific diagnostic fields.",
            "type": "object",
            "additionalProperties": true
          }
        },
        "additionalProperties": true
      },
      "PuppetryVoice": {
        "type": "object",
        "required": [
          "id",
          "object",
          "name",
          "provider",
          "language",
          "language_code",
          "gender",
          "description",
          "styles"
        ],
        "properties": {
          "id": {
            "type": "string",
            "description": "Public Puppetry voice ID.",
            "example": "puppetry-af_bella"
          },
          "object": {
            "type": "string",
            "const": "voice"
          },
          "name": {
            "type": "string",
            "example": "Bella"
          },
          "provider": {
            "type": "string",
            "const": "puppetry"
          },
          "language": {
            "type": "string",
            "example": "English"
          },
          "language_code": {
            "type": "string",
            "example": "en"
          },
          "gender": {
            "type": "string",
            "example": "Female"
          },
          "description": {
            "type": "string",
            "example": "Puppetry voice (English)"
          },
          "styles": {
            "type": "array",
            "items": {
              "type": "string"
            }
          }
        },
        "additionalProperties": false
      },
      "VoiceListResponse": {
        "type": "object",
        "required": ["object", "data"],
        "properties": {
          "object": {
            "type": "string",
            "const": "list"
          },
          "data": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/PuppetryVoice"
            }
          }
        },
        "additionalProperties": false
      },
      "TtsRequest": {
        "type": "object",
        "required": ["voice_id", "text"],
        "properties": {
          "voice_id": {
            "type": "string",
            "description": "Public voice ID from GET /api/v1/voices/puppetry.",
            "example": "puppetry-af_bella"
          },
          "text": {
            "type": "string",
            "minLength": 1,
            "maxLength": 5000,
            "description": "Text to synthesize.",
            "example": "Hello from Puppetry."
          },
          "speed": {
            "type": "number",
            "minimum": 0.5,
            "maximum": 2,
            "default": 1,
            "description": "Speech speed multiplier."
          }
        },
        "additionalProperties": false
      },
      "TtsResponse": {
        "type": "object",
        "required": [
          "object",
          "id",
          "voice_id",
          "audio_url",
          "format",
          "usage"
        ],
        "properties": {
          "object": {
            "type": "string",
            "const": "audio"
          },
          "id": {
            "type": "string",
            "description": "Generated audio asset ID."
          },
          "voice_id": {
            "type": "string",
            "example": "puppetry-af_bella"
          },
          "audio_url": {
            "type": "string",
            "format": "uri",
            "description": "Hosted URL for the generated WAV audio."
          },
          "format": {
            "type": "string",
            "const": "wav"
          },
          "usage": {
            "type": "object",
            "required": ["voice_characters"],
            "properties": {
              "voice_characters": {
                "type": "object",
                "required": ["used", "limit", "remaining"],
                "properties": {
                  "used": {
                    "type": "integer",
                    "example": 20
                  },
                  "limit": {
                    "type": "integer",
                    "example": 100000
                  },
                  "remaining": {
                    "type": "integer",
                    "example": 99980
                  }
                },
                "additionalProperties": false
              }
            },
            "additionalProperties": false
          }
        },
        "additionalProperties": false
      },
      "AudioUploadRequest": {
        "type": "object",
        "required": ["mime_type", "content_length"],
        "properties": {
          "mime_type": {
            "type": "string",
            "description": "Supported audio MIME type.",
            "enum": [
              "audio/wav",
              "audio/x-wav",
              "audio/mpeg",
              "audio/mp3",
              "audio/mp4",
              "audio/m4a",
              "audio/x-m4a"
            ],
            "example": "audio/mpeg"
          },
          "content_length": {
            "type": "integer",
            "minimum": 1,
            "maximum": 52428800,
            "description": "Audio file size in bytes.",
            "example": 1048576
          }
        },
        "additionalProperties": false
      },
      "AudioUploadUrlResponse": {
        "type": "object",
        "required": [
          "object",
          "id",
          "upload_url",
          "method",
          "headers",
          "key",
          "read_url",
          "read_url_expires_in",
          "read_url_expires_at",
          "upload_url_expires_in",
          "limits"
        ],
        "properties": {
          "object": {
            "type": "string",
            "const": "upload_url"
          },
          "id": {
            "type": "string",
            "example": "apiupl_2f4f3f1b2e9e4f63a20a0b548d4b7a8c"
          },
          "upload_url": {
            "type": "string",
            "format": "uri",
            "description": "Short-lived signed PUT URL."
          },
          "method": {
            "type": "string",
            "const": "PUT"
          },
          "headers": {
            "type": "object",
            "required": ["Content-Type", "Content-Length"],
            "properties": {
              "Content-Type": {
                "type": "string",
                "example": "audio/mpeg"
              },
              "Content-Length": {
                "type": "string",
                "example": "1048576"
              }
            },
            "additionalProperties": false
          },
          "key": {
            "type": "string",
            "description": "S3 object key for the hosted upload."
          },
          "read_url": {
            "type": "string",
            "format": "uri",
            "description": "Short-lived URL clients can use after uploading the file."
          },
          "read_url_expires_in": {
            "type": "integer",
            "example": 3600
          },
          "read_url_expires_at": {
            "type": "string",
            "format": "date-time"
          },
          "upload_url_expires_in": {
            "type": "integer",
            "example": 3600
          },
          "limits": {
            "type": "object",
            "required": [
              "max_file_bytes",
              "monthly_uploads",
              "storage_bytes",
              "remaining_monthly_uploads",
              "remaining_storage_bytes"
            ],
            "properties": {
              "max_file_bytes": {
                "type": "integer",
                "example": 52428800
              },
              "monthly_uploads": {
                "type": "integer",
                "example": 250
              },
              "storage_bytes": {
                "type": "integer",
                "example": 2147483648
              },
              "remaining_monthly_uploads": {
                "type": "integer",
                "example": 249
              },
              "remaining_storage_bytes": {
                "type": "integer",
                "example": 2146435072
              }
            },
            "additionalProperties": false
          }
        },
        "additionalProperties": false
      }
    }
  }
}
