Skip to main content
Every request to a protected MonoRelay endpoint must include a valid credential. MonoRelay supports two authentication methods: a static access key configured in config.yml, and a short-lived JWT token obtained by logging in through the auth API. Both methods use the same Authorization: Bearer header pattern, making them compatible with standard OpenAI SDKs without any special client configuration.

Authentication methods

Method 1: Access key

When server.access_key_enabled is true in your config.yml, you can authenticate by passing the configured access_key value directly. The key can be sent in either of two headers:
string
Bearer token header. Pass Bearer <your-access-key> as the value.
string
Alternative header for clients that cannot set a custom Authorization value. Pass the raw key with no Bearer prefix.
The access key is set in config.yml:
config.yml
Example using curl with the Authorization header:
Example using the X-Access-Key header:

Method 2: JWT token

User accounts created through POST /api/auth/register can obtain a JWT token by logging in. Pass the token as a Bearer credential on subsequent requests. Tokens are short-lived; use the refresh token to obtain a new access token without re-authenticating.
string
required
Bearer <jwt-token> where the token is the access_token value returned by POST /api/auth/login.
Step 1 — Log in to obtain a token:
The response includes an access_token:
Step 2 — Use the token to call an API endpoint:

Public endpoints

The following endpoints do not require authentication and can be called without any credentials:

Python SDK example

Because MonoRelay is OpenAI-compatible, you can use the official openai Python library by pointing it at your MonoRelay instance. Pass your access key or JWT token as the api_key argument.
To use a JWT token instead, replace the api_key value with the access_token string returned by POST /api/auth/login.

Error responses

If both access_key_enabled is false and no valid JWT is present, all protected endpoints return 401 Unauthorized. Ensure at least one authentication method is configured before making API calls.