Integrating BrainLink in your application allows your users to pay for their own AI spending by connecting their BrainLink account to your application with a single click.

Traditionally, most AI applications have requested users to copy/paste their API keys from other providers, however, that generates a huge amount of friction, goes against most AI providers’ terms of service and creates important security issues. Using BrainLink, users don’t need to know what’s an API key, for them, it is just a user friendly account that they can easily use with your application (and many others).

NOTE: BrainLink is NOT a key aggregator. Users do NOT have to setup BrainLink with their keys. They don’t even need to know what’s an API key to use your app if you integrate BrainLink.

And that’s all! Now your users will pay for the inference they consume by connecting their BrainLink account with your application in one click, so you don’t have to request them API keys.

Running inference

BrainLink’s API is fully OpenAI compatible, so you can directly use the OpenAI SDK or any other compatible one, just change the baseURL to https://www.brainlink.dev/api/v1.

For example:

if (BrainLink.isConnected()) {
    const userAccessToken = await BrainLink.getUserToken();
    const openai = new OpenAI({
        baseURL: "https://www.brainlink.dev/api/v1",
        apiKey: userAccessToken,
        // Required to use the OpenAI SDK in the browser.
        // Since your app is securely using the user's access token via BrainLink, it's totally safe to use the SDK on the browser.
        dangerouslyAllowBrowser: true,
    });
}

const completion = await openai?.chat.completions.create({
    model: "google/gemini-2.0-flash-lite-preview-02-05:free",
    messages: messages,
});

Shortcuts