Skip to content

This only links to pages of the documentation. It does not write answers.

Set up an OpenAI-compatible model

How-to guide

Many services and servers implement the OpenAI chat completions API, so one provider covers them all: you only choose the service and the model. Compass asks the model for probabilities as JSON and validates them.

  • Compass installed in your Starlight site.
  • An API key for a service that implements the API, or a local server like Ollama running a model with support for structured outputs.
  1. Add the plugin with the openaiCompatible() provider to your Starlight configuration. Choose the service:

    astro.config.mjs
    import starlightCompass, { openaiCompatible } from "starlight-compass";
    starlightCompass({
    provider: openaiCompatible({ model: "gpt-4o-mini" }),
    });
  2. Create a .env file in your project root with your API key, and make sure .env is listed in your .gitignore file. Local servers like Ollama need no key, so skip this step for them.

    .env
    OPENAI_API_KEY=sk-...

    The provider reads the OPENAI_API_KEY variable whatever the service is. Pass the apiKey option to read another variable.

Next, review your first page.