Introduction
M5 is a local compute gateway that turns your Ollama instance into a public API. It provides OpenAI-compatible endpoints, chat storage, and API key management.
Authentication
M5 uses Google OAuth for authentication. Sign in with your Google account to get started. After signing in, you'll receive an API key for programmatic access.
Quick Start
1. Install Ollama locally:
curl https://ollama.com/install.sh | sh
2. Pull a model:
ollama pull llama3.2
3. Sign in to M5 and get your API key
4. Make a request:
curl -X POST https://m5.hf.space/v1/chat/completions \\
-H "Authorization: Bearer YOUR_API_KEY" \\
-H "Content-Type: application/json" \\
-d '{"model":"llama3.2","messages":[{"role":"user","content":"Hello"}]}'
Chat Completions API
OpenAI-compatible chat completions endpoint.
Endpoint
POST /v1/chat/completions
Request Body
{
"model": "llama3.2",
"messages": [
{"role": "user", "content": "Hello"}
],
"temperature": 0.7,
"max_tokens": 1000,
"stream": false,
"ollama_url": "http://localhost:11434" // Optional
}
Response
{
"id": "chatcmpl-xxx",
"object": "chat.completion",
"created": 1234567890,
"model": "llama3.2",
"choices": [
{
"index": 0,
"message": {
"role": "assistant",
"content": "Hello! How can I help you?"
},
"finish_reason": "stop"
}
],
"usage": {
"prompt_tokens": 10,
"completion_tokens": 20,
"total_tokens": 30
}
}
Models API
List available Ollama models.
Endpoint
GET /v1/models
Response
{
"object": "list",
"data": [
{
"id": "llama3.2",
"object": "model",
"created": 1234567890,
"owned_by": "ollama"
}
]
}
Accounts API
Manage your account and API keys.
Get Account Info
GET /api/accounts/me
Create API Key
POST /api/accounts/api-keys
Python SDK
from m5 import M5Client
client = M5Client(api_key="your-api-key")
response = client.chat.completions.create(
model="llama3.2",
messages=[{"role": "user", "content": "Hello"}]
)
print(response.choices[0].message.content)
Tunneling
Expose your local Ollama to the cloud using ngrok:
# Start ngrok
ngrok http 11434
# Register tunnel in M5 UI or API
POST /api/accounts/ollama-tunnel
{
"ollama_public_url": "https://xxx.ngrok-free.app"
}
Rate Limits
- 60 requests per minute
- 1000 requests per day
- Custom limits available for enterprise