NanoGPT API Key Setup: Beginner Guide + Troubleshooting

setting up an API key should take 3 minutes. i've done it on multiple devices now and it's always the same process. here's exactly what you need to do, plus the errors you'll hit and how to fix them.

tl;dr: get your NanoGPT API key in 3 minutes: sign up, deposit $8, go to Settings, generate key, copy it immediately. the API is OpenAI-compatible so any code that works with OpenAI works with NanoGPT. crypto payments via Monero keep your identity separate.

Key Takeaways:

  • API key setup takes 3 minutes: sign up, deposit, generate key in Settings, copy immediately
  • NanoGPT API is fully OpenAI-compatible. any code, SDK, or tool that works with OpenAI works with NanoGPT
  • Monero and Nano deposits have zero processing fees. Bitcoin fees range $0.50-15 depending on priority

what is the NanoGPT API?

the NanoGPT API is a unified endpoint that routes your requests to different AI models. you send one request format, and NanoGPT handles the backend routing to GPT-4o, Claude, Llama, DeepSeek, and hundreds of others.

OpenAI-compatible endpoint

short answer: follows OpenAI /v1/chat/completions format. any OpenAI-compatible code works. just change base URL and API key.

the API follows the OpenAI /v1/chat/completions format. this means:

  • any code that works with OpenAI's API works with NanoGPT
  • just change the base URL and API key
  • libraries like openai-python, openai-node, and langchain work out of the box

400+ models through one API

short answer: instead of managing separate OpenAI, Anthropic, Google, and Meta accounts, get everything through NanoGPT.

instead of managing separate accounts for OpenAI, Anthropic, Google, and Meta, you get everything through NanoGPT. switch models by changing one parameter.

pay-per-prompt pricing

short answer: no monthly subscription. deposit funds via crypto or card. GPT-4o costs $0.005-0.01 per request. DeepSeek V3 costs $0.0005-0.001.

no monthly subscription. you deposit funds (crypto or card) and pay per API call. costs vary by model:

  • GPT-4o: ~$0.005 - $0.01 per request
  • Claude 3.5 Sonnet: ~$0.003 - $0.008 per request
  • Llama 3 70B: ~$0.001 - $0.003 per request
  • DeepSeek V3: ~$0.0005 - $0.001 per request

or get the $8/month flat rate for unlimited access to select models.


step 1: create your NanoGPT account

  1. go to nanogpt.com
  2. click "Sign Up"
  3. enter your email (or use crypto wallet login)
  4. verify your email

no KYC. no ID verification. just an email.

deposit options

short answer: Monero: $1 min, ~2 min. Bitcoin: $1 min, 10-30 min. Lightning: $1 min, instant. Nano: $1 min, instant. Card: $10 min, instant.

before using the API, you need credits. NanoGPT accepts:

Payment MethodMin DepositProcessing Time
Monero (XMR)$1~2 minutes
Bitcoin (BTC)$110 - 30 minutes
Bitcoin Lightning$1Instant
Nano (XNO)$1Instant
Credit Card$10Instant

for privacy, use Monero or Nano. for speed, use Lightning or Nano.


step 2: generate your API key

  1. log into your NanoGPT dashboard
  2. navigate to SettingsAPI Keys
  3. click "Generate New Key"
  4. configure permissions (see below)
  5. copy the key immediately - it's shown once

your key looks like: ng-a1b2c3d4e5f6g7h8i9j0...

key permissions

short answer: Chat Completions: required. Image Generation: optional. Model Listing: recommended. Embeddings: optional. Rate Limit: recommended for production.

when creating a key, you can set granular permissions:

Chat Completions - required. this is the main API endpoint for text generation.

Image Generation - optional. enables access to image models (DALL-E, Stable Diffusion, etc.).

Model Listing - recommended. lets your code discover available models programmatically.

Embeddings - optional. only needed if you're building RAG or semantic search systems.

Rate Limit - you can set a per-key rate limit to prevent runaway costs. recommended for production use.

security best practices

short answer: don't hardcode keys. use separate keys for dev and production. set rate limits. rotate keys if compromised.

  • don't hardcode keys in source code. use environment variables.
  • use separate keys for development and production.
  • set rate limits on keys used in public-facing applications.
  • rotate keys if you suspect they've been compromised.

step 3: make your first API call

cURL example

short answer: curl the chat completions endpoint with Bearer token authorization. response is standard OpenAI format.

curl https://api.nanogpt.com/v1/chat/completions \
  -H "Content-Type: application/json" \
  -H "Authorization: Bearer YOUR_API_KEY" \
  -d '{
    "model": "gpt-4o",
    "messages": [
      {"role": "user", "content": "Hello, what models are available?"}
    ],
    "max_tokens": 100
  }'

replace YOUR_API_KEY with your actual key. the response is standard OpenAI format:

{
  "choices": [
    {
      "message": {
        "role": "assistant",
        "content": "I can help you with various tasks..."
      }
    }
  ],
  "usage": {
    "prompt_tokens": 12,
    "completion_tokens": 25,
    "total_tokens": 37
  }
}

Python example

short answer: from openai import OpenAI, set base_url to api.nanogpt.com/v1. pip install openai.

from openai import OpenAI

client = OpenAI(
    api_key="YOUR_API_KEY",
    base_url="https://api.nanogpt.com/v1"
)

response = client.chat.completions.create(
    model="gpt-4o",
    messages=[
        {"role": "user", "content": "Explain quantum computing in one paragraph."}
    ],
    max_tokens=200
)

print(response.choices[0].message.content)

install the library: pip install openai

JavaScript example

short answer: import OpenAI, set baseURL to api.nanogpt.com/v1. npm install openai.

import OpenAI from 'openai';

const client = new OpenAI({
  apiKey: 'YOUR_API_KEY',
  baseURL: 'https://api.nanogpt.com/v1'
});

async function main() {
  const response = await client.chat.completions.create({
    model: 'gpt-4o',
    messages: [
      { role: 'user', content: 'What is the meaning of life?' }
    ],
    max_tokens: 150
  });

  console.log(response.choices[0].message.content);
}

main();

install the library: npm install openai


API key permissions explained

chat completions

short answer: the core endpoint for text generation. used by chatbots, SillyTavern, LangChain, and any OpenAI-compatible client.

the core endpoint. sends a conversation to the model and gets a response. used by:

  • chatbots
  • SillyTavern
  • LangChain applications
  • any OpenAI-compatible client

image generation

short answer: access to DALL-E 3, Stable Diffusion XL, and others through /v1/images/generations endpoint.

access to image models through the /v1/images/generations endpoint. models include DALL-E 3, Stable Diffusion XL, and others.

model listing

short answer: /v1/models returns all available models. useful for building dynamic model selectors in your application.

the /v1/models endpoint returns all available models. useful for building dynamic model selectors in your application.


troubleshooting API errors

401 Unauthorized - key invalid or expired

short answer: check for typos, verify key is active in dashboard, use Bearer token format, generate new key if revoked.

what it means: your API key is wrong, revoked, or missing.

fixes:

  1. check for typos or extra spaces in the key
  2. verify the key is active in your NanoGPT dashboard
  3. make sure you're using the key as a Bearer token: Authorization: Bearer YOUR_API_KEY
  4. if the key was revoked, generate a new one

429 Rate Limited - too many requests

short answer: add delay between requests, implement exponential backoff, upgrade to $8/month plan for higher limits.

what it means: you've hit NanoGPT's rate limit.

fixes:

  1. add a delay between requests (start with 1 second)
  2. implement exponential backoff in your code
  3. upgrade to the $8/month plan for higher limits
  4. set a per-key rate limit in NanoGPT dashboard to stay within bounds

example backoff in Python:

import time
from openai import OpenAI, RateLimitError

client = OpenAI(api_key="YOUR_API_KEY", base_url="https://api.nanogpt.com/v1")

def call_with_retry(messages, max_retries=3):
    for attempt in range(max_retries):
        try:
            return client.chat.completions.create(
                model="gpt-4o",
                messages=messages
            )
        except RateLimitError:
            wait = 2 ** attempt
            print(f"Rate limited. Waiting {wait}s...")
            time.sleep(wait)
    raise Exception("Max retries exceeded")

402 Payment Required - insufficient balance

short answer: deposit more credits, check balance in dashboard. crypto confirmations: BTC 10-30 min, XMR ~2 min, XNO instant.

what it means: your NanoGPT account has no credits.

fixes:

  1. deposit more credits at nanogpt.com
  2. check your balance in the dashboard
  3. if using crypto, wait for confirmation (BTC: 10 - 30 min, XMR: ~2 min, XNO: instant)

model not available

short answer: list available models with GET /v1/models. check spelling, try VPN for region restrictions, retry during off-peak hours.

what it means: the model name is wrong or the model is temporarily unavailable.

fixes:

  1. list available models: GET /v1/models
  2. check spelling (model names are case-sensitive)
  3. some models have region restrictions - try a VPN
  4. popular models can be temporarily unavailable during peak hours

NanoGPT API vs OpenAI API

why use NanoGPT instead of going directly to OpenAI?

FeatureNanoGPT APIOpenAI API
Models400+ (GPT, Claude, Llama, etc.)GPT + DALL-E only
PricingPay-per-prompt or $8/month flatPay-per-token (expensive)
Crypto paymentsYes (XMR, BTC, XNO)No
KYCNoneRequired
PrivacyNo logs claimedLogs everything for 30 days
Rate limitsGenerousStrict
CompatibilityOpenAI-compatibleNative

the main advantage: NanoGPT is a superset. you get everything OpenAI offers, plus Claude, Llama, DeepSeek, and 390+ other models. with better privacy and cheaper pricing.


real-world API usage examples

here are practical examples beyond basic chat:

summarization

short answer: use Gemini 1.5 Pro for long document summarization with its massive context window.

response = client.chat.completions.create(
    model="gpt-4o",
    messages=[
        {"role": "system", "content": "Summarize the following text in 3 bullet points."},
        {"role": "user", "content": "Your long text here..."}
    ]
)

code generation

short answer: use GPT-4o for code generation with system prompt specifying language and requirements.

response = client.chat.completions.create(
    model="claude-3.5-sonnet",
    messages=[
        {"role": "user", "content": "Write a Python function that validates email addresses using regex."}
    ],
    max_tokens=500
)

streaming responses

for real-time output (chatbots, UIs), use streaming:

stream = client.chat.completions.create(
    model="gpt-4o",
    messages=[{"role": "user", "content": "Tell me a story"}],
    stream=True
)

for chunk in stream:
    if chunk.choices[0].delta.content:
        print(chunk.choices[0].delta.content, end="")

streaming reduces perceived latency. the first token arrives in 0.5 - 2 seconds, even if the full response takes 10+ seconds.


API documentation: nanogpt.com/docs. Last updated: July 2026.


Ready to swap crypto privately?

No KYC. No account. Instant swaps.

Swap Now