A unified AI inference gateway for your nself backend. Route completions through OpenAI, Anthropic, Google Gemini, or a local Ollama instance, all from one OpenAI-compatible endpoint. Supports streaming, multi-provider fallback, usage tracking, and optional spend limits.
nself-ai is part of the ɳClaw bundle. It is the foundation for nself-claw, nself-mux AI features, and nself-voice. Set your key with nself license set nself_pro_... before installing.
nself license set nself_pro_...
nself plugin install ai
nself build
nself start| Variable | Required | Default | Description |
|---|---|---|---|
PLUGIN_AI_DEFAULT_PROVIDER | Yes | — | Default provider: openai, anthropic, gemini, or ollama |
PLUGIN_AI_MONTHLY_BUDGET_USD | No | unlimited | Hard monthly spend cap in USD. Requests fail with 429 when exceeded. |
| Provider | Variable | Notes |
|---|---|---|
| OpenAI | PLUGIN_OPENAI_API_KEY | Starts with sk- |
| Anthropic | PLUGIN_ANTHROPIC_API_KEY | Starts with sk-ant- |
| Google Gemini | PLUGIN_GEMINI_API_KEY | From Google AI Studio or Cloud Console |
| Ollama (local) | PLUGIN_OLLAMA_URL | Default: http://127.0.0.1:11434. No API key needed. |
Only configure the provider(s) you plan to use. Setting PLUGIN_AI_DEFAULT_PROVIDER=ollama with a local Ollama instance requires no paid API key.
# Non-streaming completion (OpenAI-compatible format)
curl -X POST http://127.0.0.1:8010/ai/v1/chat/completions \
-H "Content-Type: application/json" \
-d '{
"model": "gpt-4o",
"messages": [
{ "role": "user", "content": "What is nself?" }
]
}'The endpoint is SSE-compatible and works with the OpenAI JavaScript SDK:
import OpenAI from 'openai'
const client = new OpenAI({
baseURL: 'http://127.0.0.1:8010/ai/v1',
apiKey: 'not-used', // auth handled by nself
})
const stream = await client.chat.completions.create({
model: 'claude-3-5-sonnet-20241022',
messages: [{ role: 'user', content: 'Hello' }],
stream: true,
})
for await (const chunk of stream) {
process.stdout.write(chunk.choices[0]?.delta?.content ?? '')
}| Provider | Model IDs |
|---|---|
| OpenAI | gpt-4o, gpt-4o-mini, gpt-4-turbo, gpt-3.5-turbo, o1, o1-mini |
| Anthropic | claude-3-opus-20240229, claude-3-5-sonnet-20241022, claude-3-haiku-20240307 |
| Google Gemini | gemini-1.5-pro, gemini-1.5-flash, gemini-2.0-flash |
| Ollama | Any model installed locally: llama3.2, mistral, phi4, etc. |
The model ID in the request determines which provider handles it. The plugin auto-routes based on prefix: gpt- and o1 go to OpenAI, claude- to Anthropic, gemini- to Gemini, anything else to Ollama (or the default provider).
| Endpoint | Method | Description |
|---|---|---|
/ai/v1/chat/completions | POST | Chat completion: OpenAI-compatible, supports stream: true |
/ai/v1/models | GET | List available models across all configured providers |
/admin/usage | GET | Token usage and cost by provider, model, and day |
/admin/providers | GET | Status and health of each configured provider |
/health | GET | Plugin health check |
nself plugin remove ainself-claw and the AI features of nself-mux depend on nself-ai. Remove those plugins before removing nself-ai, or use --force.
Port: 8010 | Bundle: ɳClaw ($0.99/mo) or ɳSelf+ ($3.99/mo) | Last Updated: April 2026 | Plugin Version 1.0.12