Sequel API is built with FastAPI and is designed to be a simple and flexible framework for building GenAI APIs. From integrating authentication and usage metering to handling LLM observability, Sequel API provides a comprehensive set of tools to build and deploy GenAI APIs from day 1.
Clerk is used as the default auth platform in the demo application, but we have support any authentication provider that implements either JWKS / OpenID Connect specifications.
Sequel API builds in authentication integrations in order to more seamlessly meter usage and offer deeper observability.
Sequel API uses OpenMeter for usage metering, and is compatible with any metering backend that implements the OpenMeter API specifications. By default, Sequel API uses FastAPI middleware to meter FastAPI requests and OpenAI responses, and sends the data to OpenMeter.
- Duration
- Request UUID
- User ID
- Request Path Pattern
- Request Method
- OpenAI Chat Completion Response ID
- Platform (OpenAI)
- Model
- Prompt Tokens
- Reasoning Tokens
- Completion Tokens
- Total Tokens
- FastAPI Request UUID
These metrics are piped into OpenMeter and are versatile enough to tie most GenAI API consumption to the underlying billing model.
Soon, Sequel API will offer out-of-the-box observability with features to better understand and monitor the API's usage patterns.
All environment variables are exemplified in .env.example
.
The following environment variables should be set in your .env
file:
CLERK_PUBLIC_URL
: The public URL for your Clerk authentication service.
OPENMETER_API_SECRET_TOKEN
: The secret token for authenticating with the OpenMeter API.
OPENAI_API_KEY
: Your OpenAI API key for accessing OpenAI services.
MONGODB_CONN_STRING
: The connection string for your MongoDB database.
Make sure to set these variables with appropriate values in your .env
file before running the application.
# Generate the FastAPI build
python3 sequel.py build # this will soon become `sequel build` & the lib folder will be imported as a package
# Run the Sequel API application
fastapi run dist/src/main.py
Sequel API offers native path routing to make FastAPI development easier – for example, the GET /airports/[iata_airport_code]
endpoint is implemented in src/api/airports/[iata_airport_code]/route.py
. All route.py
scripts should expose a router: APIRouter
object that FastAPI can use to register the endpoint(s).
The plan
endpoint in src/api/airports/[iata_airport_code]/plan/route.py
offers a good example of how to implement a more complex endpoint that includes a nested router and includes a path parameter.