Outcome: Route OpenAI (or any supported provider) through your ManyLayers gateway using the standard OpenAI API. Takes about 5 minutes. This example uses OpenAI, but the same steps work for Anthropic, Azure OpenAI, Gemini, Bedrock, Cohere, and 14 other providers — just change the provider type and credentials.

Prerequisites

  • ManyLayers installed and running (see Installation)
  • An OpenAI API key
  • Your ManyLayers admin API key

Steps

1

Add the provider credentials

Register your OpenAI API key with ManyLayers. Your key is stored encrypted and never exposed in logs or responses.
curl -X POST http://localhost:8180/admin/providers \
  -H "Authorization: Bearer $ADMIN_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "name": "openai-main",
    "type": "openai",
    "api_key": "sk-..."
  }'
2

Create a logical model

A logical model is the name your clients use to make requests. It maps to a specific provider and model. Your applications call gpt-4o — ManyLayers routes it to the right upstream.
curl -X POST http://localhost:8180/admin/models \
  -H "Authorization: Bearer $ADMIN_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "name": "gpt-4o",
    "provider_id": "openai-main",
    "upstream_model": "gpt-4o"
  }'
3

Create a team and allow the model

Teams control which models each group of users can access. Create a team and add gpt-4o to its allow-list.
curl -X POST http://localhost:8180/admin/teams \
  -H "Authorization: Bearer $ADMIN_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "name": "my-team",
    "allowed_models": ["gpt-4o"],
    "rpm_limit": 100
  }'
4

Create an API key for the team

Generate a key scoped to your team. This is what your applications will use to authenticate.
curl -X POST http://localhost:8180/admin/keys \
  -H "Authorization: Bearer $ADMIN_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "name": "my-app-key",
    "team_id": "my-team"
  }'
Save the returned key — it starts with ml- and cannot be retrieved again.
5

Make your first call

Use the standard OpenAI API format. Point the base URL at ManyLayers and use your team key.
curl http://localhost:8180/v1/chat/completions \
  -H "Authorization: Bearer ml-your-key-here" \
  -H "Content-Type: application/json" \
  -d '{
    "model": "gpt-4o",
    "messages": [{"role": "user", "content": "Hello from ManyLayers!"}]
  }'
You can also use the OpenAI SDK with a single base URL change:
from openai import OpenAI

client = OpenAI(
    api_key="ml-your-key-here",
    base_url="http://localhost:8180/v1"
)

response = client.chat.completions.create(
    model="gpt-4o",
    messages=[{"role": "user", "content": "Hello from ManyLayers!"}]
)

What’s happening under the hood

Your request flows through auth, RBAC (checking your team’s model allow-list), rate limits, and then routes to OpenAI. The response is logged to the audit trail with token counts. You can see this in Metrics and Audit logs immediately.

Next steps