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, andlangchainwork 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
- go to nanogpt.com
- click "Sign Up"
- enter your email (or use crypto wallet login)
- 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 Method | Min Deposit | Processing Time |
|---|---|---|
| Monero (XMR) | $1 | ~2 minutes |
| Bitcoin (BTC) | $1 | 10 - 30 minutes |
| Bitcoin Lightning | $1 | Instant |
| Nano (XNO) | $1 | Instant |
| Credit Card | $10 | Instant |
for privacy, use Monero or Nano. for speed, use Lightning or Nano.
step 2: generate your API key
- log into your NanoGPT dashboard
- navigate to Settings → API Keys
- click "Generate New Key"
- configure permissions (see below)
- 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:
- check for typos or extra spaces in the key
- verify the key is active in your NanoGPT dashboard
- make sure you're using the key as a Bearer token:
Authorization: Bearer YOUR_API_KEY - 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:
- add a delay between requests (start with 1 second)
- implement exponential backoff in your code
- upgrade to the $8/month plan for higher limits
- 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:
- deposit more credits at nanogpt.com
- check your balance in the dashboard
- 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:
- list available models:
GET /v1/models - check spelling (model names are case-sensitive)
- some models have region restrictions - try a VPN
- popular models can be temporarily unavailable during peak hours
NanoGPT API vs OpenAI API
why use NanoGPT instead of going directly to OpenAI?
| Feature | NanoGPT API | OpenAI API |
|---|---|---|
| Models | 400+ (GPT, Claude, Llama, etc.) | GPT + DALL-E only |
| Pricing | Pay-per-prompt or $8/month flat | Pay-per-token (expensive) |
| Crypto payments | Yes (XMR, BTC, XNO) | No |
| KYC | None | Required |
| Privacy | No logs claimed | Logs everything for 30 days |
| Rate limits | Generous | Strict |
| Compatibility | OpenAI-compatible | Native |
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.
Related Guides
- SillyTavern + NanoGPT Setup - Connect your API key to SillyTavern.
- NanoGPT Review - Full review with pricing and model comparison.
- NanoGPT vs ChatGPT - Is NanoGPT better than ChatGPT Plus?
- OpenRouter Alternatives - Compare NanoGPT with other SillyTavern backends.