EN ▾
Get API key

Ollama API Key: Do You Need One and Where to Get It

Illustration of a glowing key above a terminal with flowing data, representing an API key setup

Looking for an Ollama API key? A local Ollama server does not issue one, so the key you need comes from whichever hosted service you connect to. Here is how to get one for this endpoint and use it safely.

Updated

Key points

  • A local Ollama install has no key system; clients only ask for a placeholder.
  • A hosted API needs a real key sent as a bearer token on every request.
  • Sign up with Google or email, claim the $0.50 trial in one click, no card needed.
  • Keep the key in an environment variable and call the API from a server, not from browser code.

Why the field exists if Ollama has no keys

The question usually starts in a settings screen. An app asks for an API key, you are running Ollama on your own computer, and nothing in the Ollama install seems to produce one. That is expected. A local server has no accounts and no billing, so there is nothing to authenticate against. Clients that insist on the field are usually built for the OpenAI format, and they let you type any string because the server ignores it.

So the phrase, in practice, means one of two things. Either you want to satisfy a client that demands a value for a local server, in which case a dummy like ollama is enough, or you want to call a model without running it yourself, in which case you need a real key from a hosted provider. This page is about the second case. The endpoint here is OpenAI-compatible, so everything that works with a local Ollama server through its /v1 layer can be pointed at it after you swap the base URL and the key.

It is a text-only service. One open-weight model, run by an independent provider and tuned to answer without content refusals for lawful adult use, is available under the model ID uncensored. There is no image, audio or video generation, no embeddings and no fine-tuning, and content involving minors is never allowed.

Create your key step by step

  1. Open the key page. Go to the API key page and sign up. You can use a Google account, or an email address with a password.
  2. Claim the trial. After sign-up, the key page shows a button for $0.50 of trial credit. One click claims it. It needs no card, is limited to one per person, and is valid for 7 days.
  3. Copy the key. The key is shown on the same page. Copy it into a password manager or a secrets file straight away.
  4. Test it. Run the model list call below. If it returns JSON, the key works.
  5. Top up when you are ready. The trial is for testing. For regular use, add prepaid credit from the same account.
curl https://api.ollamauncensored.cc/v1/models   -H "Authorization: Bearer YOUR_KEY"

The model list is a good first test because it costs nothing and fails loudly on a bad key. The same header, Authorization: Bearer YOUR_KEY, goes on every other call, including POST /v1/chat/completions.

A note on trial limits: a trial key is capped at 2 concurrent requests and 60 requests per minute. A full key gets 8 concurrent requests and 300 requests per minute. If your test script fires a dozen requests at once on the trial, expect some HTTP 429 responses. That is the limit working as designed, not a fault in your key.

Use the key from code

Any OpenAI client takes the key the same way. In Python:

import os
from openai import OpenAI

client = OpenAI(
    base_url="https://api.ollamauncensored.cc/v1",
    api_key=os.environ["API_KEY"],
)

reply = client.chat.completions.create(
    model="uncensored",
    messages=[{"role": "user", "content": "Write a two-line limerick about keys."}],
    max_tokens=80,
)
print(reply.choices[0].message.content)
print(reply.usage)

The max_tokens argument is optional. Without it the completion can use whatever remains of the 100,000-token window, so setting a cap is a cheap way to keep a runaway reply from costing more than you planned. In Node the shape is the same with baseURL and apiKey:

import OpenAI from "openai";

const client = new OpenAI({
  baseURL: "https://api.ollamauncensored.cc/v1",
  apiKey: process.env.API_KEY,
});

const out = await client.chat.completions.create({
  model: "uncensored",
  messages: [{ role: "user", content: "Name one use for a prepaid key." }],
});
console.log(out.choices[0].message.content);

Every response carries an X-Balance-USD header with the credit you have left, plus X-Request-Id for tracing and rate-limit headers that show your ceiling. Logging the balance header in a long-running job is a simple way to notice when a top-up is due before requests start failing.

Keep the key safe

A key is a bearer token. Whoever holds the string can spend your credit, so treat it like a password.

  • Use environment variables. Read the key from API_KEY or OPENAI_API_KEY, never from a literal in the source file. The OpenAI SDKs read OPENAI_API_KEY automatically.
  • Do not commit it. Add .env to .gitignore before the first commit. A key pushed to a public repository should be considered exposed.
  • Keep it out of the browser. Front-end JavaScript is readable by every visitor. Put a small server route between your page and the API, and store the key there.
  • Use separate environments. If you run a staging copy of an app, give it its own small balance rather than sharing the production key.
  • Watch the balance. Unexpected drops in X-Balance-USD are an early sign that a key leaked or a loop is running away.

Because the service is prepaid, the worst case is bounded by what you have loaded. That is one practical reason to top up modestly at first rather than putting in the maximum.

What the key costs to use

There is no monthly fee. You load credit and it is drawn down per request: $0.15 per 1M input tokens and $0.50 per 1M output tokens. Failed or refused requests are not charged, and credit never expires, so a small balance can sit unused without losing value.

A worked example. A chat turn with 2,000 input tokens and 500 output tokens costs 2,000 x $0.15 / 1,000,000 = $0.0003 for input, plus 500 x $0.50 / 1,000,000 = $0.00025 for output. That is $0.00055 per turn. The $0.50 trial credit covers roughly 900 turns of that size, which is plenty to test a prototype, a character setup or a prompt chain.

Top-ups are any whole amount from $20 to $500. Bonuses apply on larger amounts: +5% from $50, +10% from $100, +15% from $200. So a $50 top-up gives $52.50 of credit, $100 gives $110, and $200 gives $230. You can pay by crypto (USDT on TRC20, USDC on Base). The pricing page lists the details, and the docs cover streaming, tool calling and JSON mode once your key is working.

Prompts are not used for training, which matters if you are testing with private character cards or draft text.

Using the key in other tools

You do not need to write code to use the key. Chat frontends such as SillyTavern, Open WebUI and LibreChat each have a connection screen with three fields: the base URL https://api.ollamauncensored.cc/v1, the key, and the model ID uncensored. Paste the key with no quotes around it. Agent frameworks and notebooks usually read OPENAI_API_KEY, so exporting that variable once covers several programs at the same time.

When you move from a local Ollama setup, hunt down every place the old placeholder key was stored. Desktop apps often keep one copy per profile, and a leftover dummy value will produce an authentication error that looks like a service problem. Search your .env files, shell profile and each app's settings. A good habit is to name the variable after the service rather than reuse a generic name, so you always know which key a script is using.

If you run several projects, you can share one account and one balance across them. The trade-off is that one runaway loop in any project spends from the same pool, so keep an eye on the X-Balance-USD header and set sensible max_tokens values in each.

If the key does not work

Start with the plain causes. A key copied from a chat window often carries a trailing space or newline, which makes the bearer token invalid. Paste it into a text editor first, or strip whitespace in code. Make sure the header reads Authorization: Bearer followed by a single space and the key. Confirm that the base URL is the hosted one and not the old localhost:11434.

If calls succeed in a script but fail in an app, check how the app stores the key. Some apps keep it per connection profile, so editing the global field changes nothing. If you see HTTP 429 with the code rate_limited, slow down; with concurrency, reduce simultaneous requests; with a Retry-After: 5 header, the service is briefly overloaded and a retry after five seconds is the right response. For anything else, send the X-Request-Id from the failing response to support.

Questions and answers

Does Ollama itself give me an API key?

No. A local Ollama server has no accounts or key system. Clients that require the field accept any placeholder string, because the local server ignores it.

Is the trial really free?

Yes. New users can claim $0.50 of trial credit with one click on the key page. It needs no card, is one per person, and lasts 7 days.

Can I put the key in front-end JavaScript?

You should not. Anyone can read browser code. Keep the key on a server and have your page call that server instead.

Where do I send the key?

In the Authorization header as a bearer token on every request to https://api.ollamauncensored.cc/v1, for example on POST /v1/chat/completions.

Your key is one form away

Create an account, copy the key, change the base URL. That is the whole setup.