Skip to main content

NanoGPT

Overview​

PropertyDetails
DescriptionNanoGPT is a pay-per-prompt and subscription based AI service providing instant access to over 200+ powerful AI models with no subscriptions or registration required.
Provider Route on LiteLLMnano-gpt/
Link to Provider DocNanoGPT Website ↗
Base URLhttps://nano-gpt.com/api/v1
Supported Operations/chat/completions, /completions, /embeddings

What is NanoGPT?​

NanoGPT is a flexible AI API service that offers:

  • Pay-Per-Prompt Pricing: No subscriptions, pay only for what you use
  • 200+ AI Models: Access to text, image, and video generation models
  • No Registration Required: Get started instantly
  • OpenAI-Compatible API: Easy integration with existing code
  • Streaming Support: Real-time response streaming
  • Tool Calling: Support for function calling

Required Variables​

Environment Variables
os.environ["NANOGPT_API_KEY"] = ""  # your NanoGPT API key

Get your NanoGPT API key from nano-gpt.com.

Usage - LiteLLM Python SDK​

Non-streaming​

NanoGPT Non-streaming Completion
import os
import litellm
from litellm import completion

os.environ["NANOGPT_API_KEY"] = "" # your NanoGPT API key

messages = [{"content": "What is the capital of France?", "role": "user"}]

# NanoGPT call
response = completion(
model="nano-gpt/model-name", # Replace with actual model name
messages=messages
)

print(response)

Streaming​

NanoGPT Streaming Completion
import os
import litellm
from litellm import completion

os.environ["NANOGPT_API_KEY"] = "" # your NanoGPT API key

messages = [{"content": "Write a short poem about AI", "role": "user"}]

# NanoGPT call with streaming
response = completion(
model="nano-gpt/model-name", # Replace with actual model name
messages=messages,
stream=True
)

for chunk in response:
print(chunk)

Tool Calling​

NanoGPT Tool Calling
import os
import litellm

os.environ["NANOGPT_API_KEY"] = ""

tools = [
{
"type": "function",
"function": {
"name": "get_weather",
"description": "Get current weather",
"parameters": {
"type": "object",
"properties": {
"location": {"type": "string"}
}
}
}
}
]

response = litellm.completion(
model="nano-gpt/model-name",
messages=[{"role": "user", "content": "What's the weather in Paris?"}],
tools=tools
)

Usage - LiteLLM Proxy Server​

1. Save key in your environment​

export NANOGPT_API_KEY=""

2. Start the proxy​

model_list:
- model_name: nano-gpt-model
litellm_params:
model: nano-gpt/model-name # Replace with actual model name
api_key: os.environ/NANOGPT_API_KEY

Supported OpenAI Parameters​

NanoGPT supports all standard OpenAI-compatible parameters:

ParameterTypeDescription
messagesarrayRequired. Array of message objects with 'role' and 'content'
modelstringRequired. Model ID from 200+ available models
streambooleanOptional. Enable streaming responses
temperaturefloatOptional. Sampling temperature
top_pfloatOptional. Nucleus sampling parameter
max_tokensintegerOptional. Maximum tokens to generate
frequency_penaltyfloatOptional. Penalize frequent tokens
presence_penaltyfloatOptional. Penalize tokens based on presence
stopstring/arrayOptional. Stop sequences
nintegerOptional. Number of completions to generate
toolsarrayOptional. List of available tools/functions
tool_choicestring/objectOptional. Control tool/function calling
response_formatobjectOptional. Response format specification
userstringOptional. User identifier

Model Categories​

NanoGPT provides access to multiple model categories:

  • Text Generation: 200+ LLMs for chat, completion, and analysis
  • Image Generation: AI models for creating images
  • Video Generation: AI models for video creation
  • Embedding Models: Text embedding models for vector search

Pricing Model​

NanoGPT offers a flexible pricing structure:

  • Pay-Per-Prompt: No subscription required
  • No Registration: Get started immediately
  • Transparent Pricing: Pay only for what you use

API Documentation​

For detailed API documentation, visit docs.nano-gpt.com.

Additional Resources​