Are you an LLM? Read llms.txt for a summary of the docs, or llms-full.txt for the full context.
Skip to content
Guides

OpenAI-compatible services

Mubit takes calls for four services that speak the OpenAI API: OpenRouter, Groq, Together and Mistral. Use the OpenAI SDK, or plain HTTP, with the service's base URL under Mubit.

Before you start

Add your key for the service, unless the console lists that service among the providers the starter credit covers.

  1. In the sidebar, under Workspace, open Provider keys.
  2. Select Add key.
  3. Under Provider, choose OpenAI-compatible.
  4. Under Service, choose the service.
  5. Paste the service's key in API key.
  6. Select Check and save.

Base URL

Each service has its own base URL. The service's name is part of the path, and the base URL ends in /v1.

ServiceBase URL
OpenRouterhttps://api.mubit.ai/compat/openrouter/v1
Groqhttps://api.mubit.ai/compat/groq/v1
Togetherhttps://api.mubit.ai/compat/together/v1
Mistralhttps://api.mubit.ai/compat/mistral/v1

Use the base URL your console's Connect page shows. It shows these on its OpenAI-compatible line: choose the service under Service.

Send a call

Pass your Mubit key as the API key. The examples use OpenRouter and read the key from MUBIT_API_KEY. Replace MODEL_ID with a model ID of the service, as the service names it.

Python
import os
from openai import OpenAI
 
client = OpenAI(
    base_url="https://api.mubit.ai/compat/openrouter/v1",
    api_key=os.environ["MUBIT_API_KEY"],
)
 
instructions = (
    "Sort the support message into one category: "
    "billing, bug, account or other. Reply with the category only."
)
 
response = client.chat.completions.create(
    model="MODEL_ID",
    messages=[
        {"role": "system", "content": instructions},
        {"role": "user", "content": "I was charged twice for my October invoice."},
    ],
)
print(response.choices[0].message.content)

The TypeScript example uses top-level await, so run it as an ES module: save the file as compat.mts and run npx tsx compat.mts, or add "type": "module" to your package.json.

For another service, change openrouter in the base URL to groq, together or mistral.

What these base URLs serve

These paths: POST /chat/completions, POST /embeddings, GET /models and GET /models/{id}. Any other path or method gets 404 unknown_route. A service name that isn't in the table gets 404 unknown_provider, and the message lists the services.

If you have no key saved for the service and the starter credit doesn't cover it, the call gets 403 provider_key_missing.

See the call in Requests

  1. In the console, open Requests.
  2. Find your call at the top. The list is newest first.
  3. Check Model asked. It shows the model ID your app sent.

What Mubit forwards and trains on

  • Forwarded: when Mubit sends a call on to the service, it sends your request with your key for that service, or the starter credit's key where the console lists that service under the starter credit, in place of your Mubit key. It doesn't pass on cookies, x-middleware-store or x-middleware-record.
  • Trained on: adapters train only on kept examples: the recorded calls Mubit accepts for a task. A call recorded without its request and reply is never a kept example.

Frameworks and coding tools

Coding tools shows Aider with a service's base URL.

If a call fails

The error names its code. Troubleshooting lists the codes and what to do.