Quick Start
Get up and running with AiMo Network in just a few minutes.
What You'll Learn
This quick start guide will help you:
- Create your account and generate an API key
- Fund your account with USDC
- Make your first inference request
- Understand the X402 payment system
Prerequisites
- Basic understanding of AI/ML models and APIs
- Internet connection
- USDC for payments (optional - you can also use X402 direct payments)
Step 1: Visit the Web Console
Go to the AiMo Network Dashboard to access your account.
Step 2: Generate Your API Key
Generate your API key through the dashboard:
- Navigate to the API Keys section
- Click "Generate API Key"
- Copy and securely store your API key
Your API key will look like this:
aimo-sk-v2-[base58-encoded-key]Step 3: Fund Your Account
Add USDC to your account for AI inference payments:
- Visit the Balance section
- Add USDC to your account
- Payments will be processed automatically using the X402 protocol
Step 4: Make Your First Request
Using cURL
curl -X POST "https://devnet.aimo.network/api/v1/chat/completions" \
-H "Authorization: Bearer aimo-sk-v2-[your-api-key]" \
-H "Content-Type: application/json" \
-d '{
"model": "openai/gpt-4o",
"messages": [
{"role": "user", "content": "Hello! Can you help me understand AiMo Network?"}
],
"stream": false,
"max_tokens": 50
}'Using Python
import requests
import json
url = "https://devnet.aimo.network/api/v1/chat/completions"
headers = {
"Authorization": "Bearer aimo-sk-v2-[your-api-key]",
"Content-Type": "application/json"
}
data = {
"model": "anthropic/claude-3-5-sonnet",
"messages": [
{"role": "user", "content": "Hello! Can you help me understand AiMo Network?"}
],
"stream": False,
"max_tokens": 50
}
response = requests.post(url, headers=headers, json=data)
print(response.json())Using JavaScript/Node.js
const response = await fetch('https://devnet.aimo.network/api/v1/chat/completions', {
method: 'POST',
headers: {
'Authorization': 'Bearer aimo-sk-v2-[your-api-key]',
'Content-Type': 'application/json'
},
body: JSON.stringify({
model: 'deepseek/deepseek-chat',
messages: [
{ role: 'user', content: 'Hello! Can you help me understand AiMo Network?' }
],
stream: false,
max_tokens: 100
})
});
const data = await response.json();
console.log(data.choices[0].message.content);Step 5: Finding Available Models
There are several ways to discover available models:
1. List Models via API
curl "https://devnet.aimo.network/api/v1/models" \
-H "Authorization: Bearer aimo-sk-v2-[your-api-key]"2. Browse the Marketplace
Visit https://aimo.network/marketplace to explore available models with their capabilities and pricing.
Model Format Options
Intelligent Routing (Recommended): Use simple model names for automatic routing:
openai/gpt-4oanthropic/claude-3-5-sonnetdeepseek/deepseek-chat
Direct Provider: Route to a specific provider:
provider_pubkey:model_name
Common Use Cases
Text Generation
import requests
response = requests.post("https://devnet.aimo.network/api/v1/chat/completions",
headers={"Authorization": "Bearer aimo-sk-v2-[your-key]", "Content-Type": "application/json"},
json={
"model": "openai/gpt-4o",
"messages": [
{"role": "system", "content": "You are a helpful writing assistant."},
{"role": "user", "content": "Write a product description for a smart water bottle."}
]
}
)Code Generation
response = requests.post("https://devnet.aimo.network/api/v1/chat/completions",
headers={"Authorization": "Bearer aimo-sk-v2-[your-key]", "Content-Type": "application/json"},
json={
"model": "anthropic/claude-3-5-sonnet",
"messages": [
{"role": "user", "content": "Write a Python function to calculate fibonacci numbers"}
]
}
)Streaming Responses
response = requests.post("https://devnet.aimo.network/api/v1/chat/completions",
headers={"Authorization": "Bearer aimo-sk-v2-[your-key]", "Content-Type": "application/json"},
json={
"model": "deepseek/deepseek-chat",
"messages": [{"role": "user", "content": "Tell me about AI"}],
"stream": True
},
stream=True
)
for line in response.iter_lines():
if line.startswith(b'data: '):
data = line[6:].decode('utf-8')
if data == '[DONE]':
break
print(data)Understanding Costs and Payments
AiMo Network uses the X402 protocol for decentralized payments:
How Payments Work
- Account Funding: Add USDC to your account via the dashboard
- Automatic Processing: When you make requests with an API key, payments are processed automatically using Coinbase server wallets
- Usage-Based Billing: You're charged only for actual token usage
- Transparent Pricing: Each provider sets their own pricing per token
Response Format
Each request returns usage information for billing:
{
"choices": [...],
"usage": {
"prompt_tokens": 25,
"completion_tokens": 75,
"total_tokens": 100
}
}Payment Calculation
- Token Usage: Based on input tokens (prompt) and output tokens (completion)
- Provider Pricing: Each provider sets their own pricing per token
- Blockchain Settlement: Payments are settled using X402 protocol on Solana or Base
Error Handling
Always implement proper error handling for common issues:
import requests
try:
response = requests.post("https://devnet.aimo.network/api/v1/chat/completions",
headers={"Authorization": "Bearer aimo-sk-v2-[your-key]", "Content-Type": "application/json"},
json={
"model": "openai/gpt-4o",
"messages": [{"role": "user", "content": "Hello"}]
}
)
if response.status_code == 200:
data = response.json()
print(data['choices'][0]['message']['content'])
elif response.status_code == 401:
print("Error: Invalid API key")
elif response.status_code == 402:
print("Error: Insufficient balance")
elif response.status_code == 404:
print("Error: Model not found")
else:
print(f"Error {response.status_code}: {response.text}")
except Exception as e:
print(f"Network error: {e}")Best Practices
- Store API keys securely - Use environment variables, never expose in code
- Handle errors gracefully - Implement retry logic with exponential backoff
- Monitor account balance - Keep sufficient USDC for your usage patterns
- Use intelligent routing - Use simple model names (e.g.,
openai/gpt-4o) for automatic provider selection - Implement streaming - Use streaming for better user experience with longer responses
Next Steps
Now that you've made your first request:
- Learn about authentication - Understand API key generation and management
- Explore API usage - Learn about the full API capabilities
- Set up payments - Understand the escrow system and billing
- Implement streaming - Add real-time response streaming
- Handle errors - Robust error handling strategies
- Integration examples - OpenAI library compatibility and more
- Read the user guide - Comprehensive documentation
Troubleshooting
Common Issues
Authentication Error (401)- Verify your API key format:
aimo-sk-v2-[base58-encoded-key] - Ensure it's included in the Authorization header
- Generate a new key if needed via the dashboard
- Your account has insufficient USDC
- Top up your account at https://aimo.network/account/balance
- Verify the model name is correct
- Check available models via
GET /v1/modelsor browse the marketplace - Try using intelligent routing format (e.g.,
openai/gpt-4o)
Getting Help
- Documentation: Browse the user guide and provider guide
- Dashboard: Manage your account at https://aimo.network/account
- Community: Join our Discord server
- Support: Contact support@aimo.network
Congratulations! 🎉 You've successfully made your first request to AiMo Network. Ready to build something amazing?