Table of contents
Replicate's public HTTP API documentation is available as a machine-readable OpenAPI schema in JSON format.
👉 Download the schema at api.replicate.com/openapi.json
OpenAPI (formerly known as Swagger) is a specification for describing the structure of HTTP APIs, including all their endpoints, HTTP methods, input parameters, request and response formats, and other metadata.
OpenAPI schemas are useful as raw reference material when learning about an API, but they're also great for dynamically generating client libraries, reference documentation, tests, and tools for interacting with HTTP APIs.
OpenAPI is also the industry-standard format for AI function calling (also called "tool use"), which enables products like Anthropic Claude and OpenAI GPT Actions to auto-discover the structure of HTTP APIs and interact with them dynamically.
Here's an example using cURL and jq to print all the API paths in your terminal:
OpenAPI schemas are written in JSON Schema, a format which allows you to have multiple references to the same object (see $ref
). References are great for keeping the schema DRY (Don't Repeat Yourself), but they can make the schema a bit harder to read and use as a consumer.
To make the schema easier to work with, it's helpful to "dereference" it. This means replacing all the references with the actual objects.
Here's an example of how $ref
s appear in the schema:
And here's what that same object looks like after dereferencing:
There are many open-source libraries for dereferencing OpenAPI schemas.
Here's some example code showing how to dereference Replicate's OpenAPI schema using Node.js and the popular and well-maintained @apidevtools/json-schema-ref-parser npm package:
That will print the entire dereferenced schema to the console:
Every model on Replicate also has its own API schema.
You can programmatically fetch the full input and output schema for any Replicate model using the models.get
API endpoint.
Here's an example using cURL and jq to print the input schema for the black-forest-labs/flux-schnell model:
And here's the output:
To learn more about how Replicate model interfaces are defined, see the Cog documentation.