Skip to content
Documentation menu

Use AI

Use AI in your apps.

Any app that lets you set a custom OpenAI base URL works with Ompera. You need three values.

  1. Get the three values

    Base URLhttps://api.ompera.net/v1
    API keyCreate one in Workspace → API keys.
    ModelCopy an address from Workspace → Models: your own (my/local), one from your pools (HomeLab/qwen3-4b) or one from the Ompera network.

    Turn on Allow Unshielded models when you create the key to use models connected from a computer, yours or from your pools. Ompera network models work with any key.

  2. Paste them into your app

    In the examples, replace MODEL_ADDRESS with your model address.

    Any app

    Look for OpenAI-compatible, custom provider or base URL in the app's settings and enter the three values. Choose the Chat Completions API if asked; the newer Responses API is not supported yet.

    Apps with a model picker read the list from GET /v1/models; in others, type the model address. Tools built on the OpenAI SDK often read the OPENAI_BASE_URL and OPENAI_API_KEY environment variables: set them to the base URL and your Ompera key.

    OpenCode

    Save as opencode.json in your project (or merge into ~/.config/opencode/opencode.json), set OMPERA_API_KEY in your environment and pick the Ompera model in OpenCode.

    {
      "$schema": "https://opencode.ai/config.json",
      "provider": {
        "ompera": {
          "npm": "@ai-sdk/openai-compatible",
          "name": "Ompera",
          "options": {
            "baseURL": "https://api.ompera.net/v1",
            "apiKey": "{env:OMPERA_API_KEY}"
          },
          "models": { "MODEL_ADDRESS": { "name": "Ompera model" } }
        }
      }
    }

    Python

    With the official OpenAI SDK (pip install openai).

    import os
    from openai import OpenAI
    
    client = OpenAI(base_url="https://api.ompera.net/v1", api_key=os.environ["OMPERA_API_KEY"])
    reply = client.chat.completions.create(
        model="MODEL_ADDRESS",
        messages=[{"role": "user", "content": "Hello!"}],
    )
    print(reply.choices[0].message.content)

    To show the answer while it's written, add stream=True (example).

    JavaScript

    With the official OpenAI SDK (npm install openai).

    import OpenAI from "openai";
    
    const client = new OpenAI({ baseURL: "https://api.ompera.net/v1", apiKey: process.env.OMPERA_API_KEY });
    const reply = await client.chat.completions.create({
      model: "MODEL_ADDRESS",
      messages: [{ role: "user", content: "Hello!" }],
    });
    console.log(reply.choices[0].message.content);

    To show the answer while it's written, add stream: true (example).

    Frameworks

    LangChain (pip install langchain-openai):

    import os
    from langchain_openai import ChatOpenAI
    
    llm = ChatOpenAI(model="MODEL_ADDRESS", base_url="https://api.ompera.net/v1", api_key=os.environ["OMPERA_API_KEY"])
    print(llm.invoke("Hello!").content)

    Vercel AI SDK (npm install ai @ai-sdk/openai-compatible):

    import { createOpenAICompatible } from "@ai-sdk/openai-compatible";
    import { generateText } from "ai";
    
    const ompera = createOpenAICompatible({ name: "ompera", baseURL: "https://api.ompera.net/v1", apiKey: process.env.OMPERA_API_KEY });
    const { text } = await generateText({ model: ompera("MODEL_ADDRESS"), prompt: "Hello!" });
    console.log(text);

    curl

    A quick check from the terminal.

    curl https://api.ompera.net/v1/chat/completions \
      -H "Authorization: Bearer $OMPERA_API_KEY" \
      -H "Content-Type: application/json" \
      -d '{"model":"MODEL_ADDRESS","messages":[{"role":"user","content":"Hello!"}]}'

    List the models your key can use: curl https://api.ompera.net/v1/models -H "Authorization: Bearer $OMPERA_API_KEY"

    Your app gets answers from the model.

Got a pool invitation?

Open the link, sign in and click Join the pool. Its models appear in Workspace → Models with addresses like HomeLab/qwen3-4b. Use them with a key that allows Unshielded models; the key can also say what to do when a model goes offline (details).

Before you ship

  • Timeouts. Allow at least 5 minutes per request. A busy model first waits in line for up to 30 seconds, and models on home hardware can be slow.
  • Retries. Retry 429 after Retry-After, and 502 once. Don't repeat other errors unchanged. The OpenAI SDKs already retry twice. All errors
  • Parallel requests. Up to 4 per key. A model on someone's computer answers one request at a time; a pool where several members run it answers more.
  • Offline models. An address keeps working when its model comes back. Until then requests return provider_unavailable, or the key switches to a pool model (offline setting); the X-Ompera-Model header shows which model answered.
  • Features. Streaming, tools and JSON output need the model to list them in capabilities (GET /v1/models). Tools · JSON
The first request is slow

If the model server loads models on request, the first call waits for the model to load. After that, speed depends on the model and the hardware it runs on.

Keeping keys safe

A key acts as your account for AI requests (it cannot open your workspace). Use one key per app, keep keys out of source code and public pages, and revoke a key in Workspace → API keys if it leaks.

Need translation, text from images, speech to text or embeddings? They are separate services: same key; embeddings use a fixed engine for your search index.

Got an error? See what each error means.