Recipe

Flask Primer

Spin up a tiny Flask service that proxies prompts to the Meridian gateway. This primer walks you from a blank directory to a working/chatendpoint backed by any model on the Meridian roster, with sane defaults for streaming, retries, and key rotation.

1.

Install & scaffold

Create a virtual environment and install Flask plus the OpenAI SDK (Meridian speaks the OpenAI wire protocol, so any compatible client works).

python -m venv .venv
source .venv/bin/activate
pip install flask openai python-dotenv
2.

Wire the gateway

Point the OpenAI client athttps://llm.getnimbus.net/v1and pass your Meridian key. Define a single route that accepts a JSON payload and forwards it untouched.

from flask import Flask, request, jsonify
from openai import OpenAI
import os

app = Flask(__name__)
client = OpenAI(
    base_url="https://llm.getnimbus.net/v1",
    api_key=os.environ["MERIDIAN_KEY"],
)

@app.route("/chat", methods=["POST"])
def chat():
    body = request.get_json()
    resp = client.chat.completions.create(
        model=body.get("model", "azure/model-router"),
        messages=body["messages"],
    )
    return jsonify(resp.model_dump())
3.

Run & probe

Export your key, start the dev server, and hit the endpoint with curl. The adaptive router will pick a model that fits the prompt shape and return a standard chat completion envelope.

export MERIDIAN_KEY=sk-mer-...
flask --app app run --port 8080

curl -s localhost:8080/chat \
  -H 'content-type: application/json' \
  -d '{"messages":[{"role":"user","content":"hi"}]}'