7,5 KiB
name: all-in-one-ai description: Use Interweb Mozambique All in One AI from Claude Code: list AI models and prices, ask other text models or the user's agents, generate images, videos and speech, follow generations until they finish, search the web and check the AI credit balance, through the interweb-ai MCP server or the REST API. Use when the user asks to generate an image, video, voice or audio file, to call or compare another AI model, or to check AI credits.
Interweb Mozambique All in One AI
All in One AI gives access to many text, image, video and audio models, paid with the user's AI credits (or Coding Plan points for the text models in the plan).
Setup
- API address:
https://api.interweb.co.mz/v1. It is fixed for Interweb Mozambique: never ask the user for another address. - API key: always read it from the
INTERWEB_API_KEYenvironment variable. Check it without printing it:test -n "$INTERWEB_API_KEY" && echo set || echo missing - If it is missing, ask the user to create a key in the API Center (https://www.meu.interweb.co.mz/api-center.php) with
ai:readandai:write, then to runexport INTERWEB_API_KEY="sandbox_..."and restart Claude Code (or the editor). sandbox_keys read the real account but only simulate writes and never charge.prod_keys change the account and can charge.GET /v1/tokengives the mode indata.modeand the permissions indata.permissions. Suggest asandbox_key for a first try.- Never print, log or commit the key, and never put it in code that runs in a browser or a mobile app. In code, read it from the environment.
Every request looks like this:
curl -sS "https://api.interweb.co.mz/v1/PATH" -H "Authorization: Bearer $INTERWEB_API_KEY" -H "Accept: application/json"
Rules
- Before anything that charges, deletes data or cannot be undone, tell the user exactly what will happen (with the price, when the API gives one) and wait for a clear yes.
- Send an
Idempotency-Keyheader on purchases, sends and other POST requests that accept it, and reuse the same value if you retry the same request:IDEM=$(uuidgen 2>/dev/null || cat /proc/sys/kernel/random/uuid). - Lists come in pages:
?page=1&per_page=100, andmeta.total_pagessays how many there are. - Long operations answer
202with anaction_id. Follow them withGET /v1/actions/{action_id}every 10 to 20 seconds untilstatusisdoneorfailed. - Answer the user in the language they write in, and show amounts with the currency the API returns.
MCP tools first
If the MCP server is connected (in Claude Code the tools are named like mcp__interweb-ai__generate_image, or with the plugin prefix), use its tools:
| Tool | Use it to | Arguments |
|---|---|---|
list_models |
Find model ids and prices in credits | type (text, image, video, audio, agent), q, limit |
get_model |
See the input fields of a media model | id |
generate_image |
Create an image | prompt, optional model, options |
generate_video |
Create a video from text or an image | prompt, optional model, image_url, options |
generate_audio |
Create speech or sound | text or prompt, optional model, options |
get_generation |
Check a generation that was still running | id |
chat |
Ask another text model or one of the user's agents | model, messages or prompt, optional system, max_tokens |
web_search |
Search the web | query |
get_balance |
See AI credits and Coding Plan points | none |
- Each
generate_*waits up to about 50 seconds. If it is not ready, it returns anid: callget_generationlater (every 10 seconds for images and audio, every 15 to 30 seconds for videos). - Errors come back with
isError: trueand a clear message. Explain it; do not retry blindly.
To add the server by hand: claude mcp add --transport http --scope user interweb-ai https://api.interweb.co.mz/mcp --header "Authorization: Bearer $INTERWEB_API_KEY". Without the header, Claude Code signs in through the browser (OAuth) with the Interweb Mozambique account.
REST API
Model ids always contain a slash. Never invent one: look it up first.
curl -sS "https://api.interweb.co.mz/v1/models?type=image&q=flux" -H "Authorization: Bearer $INTERWEB_API_KEY"
curl -sS "https://api.interweb.co.mz/v1/ai/balance" -H "Authorization: Bearer $INTERWEB_API_KEY"
curl -sS -X POST "https://api.interweb.co.mz/v1/chat/completions" -H "Authorization: Bearer $INTERWEB_API_KEY" -H "Content-Type: application/json" \
-d '{"model": "MODEL_ID", "messages": [{"role": "user", "content": "Hello"}], "max_tokens": 300}'
- The chat endpoint is OpenAI compatible: any OpenAI SDK works with
base_url="https://api.interweb.co.mz/v1"and the key fromINTERWEB_API_KEY. The API also speaks the Anthropic Messages format (POST /v1/messages) and OpenAI Responses (POST /v1/responses). - Always set
max_tokens: credits for it are reserved first and the unused part is returned. - Media:
POST /v1/media/generationswith{"model": "MODEL_ID", "input": {"prompt": "..."}}and anIdempotency-Key; it answers202withdata.id. PollGET /v1/media/generations/{id}untilstatusiscompleted(files indata.outputs) orfailed. - Output links are not permanent: download the files into the project (
curl -fsSL -o public/img/hero.png URL) and tell the user where they are.
Spending
- Listing models, reading a model, checking a generation and the balance are free. Chat, generations and web search spend credits.
- Before a video, several images or anything likely to cost more than a few credits, look up the price, estimate the total, check the balance and ask.
- Generate one result first and show it before making variations. A generation is charged even if you stop waiting: never send the same job twice.
402insufficient_credits: suggest buying credits in All in One AI (https://www.meu.interweb.co.mz/all-in-one-ai.php), a cheaper model or a lowermax_tokens.429plan_limit_reached: the Coding Plan points ran out untildetails.resets_at.
Sandbox
With a sandbox_ key nothing is charged and no model runs: chat answers a fixed test text, a generation is ready at once with a sample link and 0 credits, and the model list, prices and balance are real. If the user expects real results, tell them to switch to a prod_ key.
Errors
Errors look like {"error": {"code", "message", "correlation_id", "details"}}. Act on code, never on the text of message.
| HTTP | code | What to do |
|---|---|---|
| 401 | unauthorized |
The key is missing, wrong or revoked. Ask the user to check INTERWEB_API_KEY. |
| 402 | insufficient_credit |
Not enough account credit, and nothing was charged. Give the user details.add_funds_url. |
| 403 | insufficient_scope |
The key lacks a permission. Name it and ask for a key that has it. |
| 403 | spending_limit_exceeded |
The purchase goes over the key spending limit. Nothing was charged. |
| 404 | not_found |
Wrong id, or it is not in this account. |
| 409 | conflict and others |
Read details.reason and explain it in plain words. |
| 422 | validation_failed |
Fix the field named in details and try again. |
| 429 | rate_limited |
Wait for the Retry-After seconds, then try once more. |
| 5xx | internal_error, upstream_error |
Try again later. If the user contacts support, give them the correlation_id. |
More
- MCP: https://docs.interweb.co.mz/mcp/
- AI API: https://docs.interweb.co.mz/ia/
- aio command: https://docs.interweb.co.mz/cli/
- Full reference: https://api.interweb.co.mz/v1/openapi.json