MagnetAPI.org API Paste your MagnetAPI System Key or User API Key to authorize requests. Plain-English Documentation

MagnetAPI.org Customer API Documentation

Customer documentation mode

Use https://api.magnetapi.org as the API base. Existing OpenAI and Anthropic SDK users normally only need to replace the base URL and API key. Your permanent System Key and every active User API Key work across every supported model and customer endpoint listed below, with usage billed to the same wallet at the live internal token rate.

This public reference contains customer endpoints only. Provider administration, organization management, training, media generation, and hosted storage products are not part of the MagnetAPI coding-model service.

Download MagnetAPI SDK v1.1.0

The public SDK bundle includes typed Python, JavaScript, and TypeScript clients, automatic retries, request-id diagnostics, framework examples, streaming helpers, this customer OpenAPI schema, and explicit methods for every endpoint shown below.

python -m pip install https://magnetapi.org/downloads/magnetapi_sdk-1.1.0-py3-none-any.whl
npm install magnetapi-sdk

Power AI API guide

Exact model ID: power-ai

Power AI is a managed model alias. Send model=power-ai to use the service's configured Power AI destination. The selected provider can change without changing this model ID. Existing account billing and key restrictions apply. This is a service-managed alias, not the official name of a separate foundation model.

  1. Sign in to your MagnetAPI.org dashboard and open API Keys. Create a User API Key for your integration, or use your System Token.
  2. Use https://api.magnetapi.org as the API host. SDKs that append endpoint names normally need https://api.magnetapi.org/v1 as their base URL; do not append /v1 twice.
  3. Send Authorization: Bearer YOUR_API_KEY and model: power-ai. A dashboard login session, provider key or reseller-management key is not a substitute for the customer's model API key.
  4. Read the returned answer and usage. API calls use the account's existing wallet and saved Codex rate card. Applicable Unlimited coverage, key permissions, spending limits and expiry still apply; this model does not create free credit.

Power AI accepts Chat Completions, Responses and Anthropic-style Messages requests. The public model ID stays power-ai even when its managed destination changes. Reasoning behavior follows the current routing policy; specifying this alias does not pin a particular upstream or effort level.

Download customer OpenAPI schema. Import this schema into your API client and choose a Power AI request example. Customer inference and reseller management use separate schemas.

List available models

Bash: set API_KEY to a System Token or User API Key from this site's dashboard before running these commands.

curl --fail-with-body https://api.magnetapi.org/v1/models \
  -H "Authorization: Bearer $API_KEY"
Chat Completions

Read the assistant reply from choices[0].message.content. Inspect tool_calls if the reply asks to use a function.

curl --fail-with-body --max-time 180 https://api.magnetapi.org/v1/chat/completions \
  -H "Authorization: Bearer $API_KEY" \
  -H "Content-Type: application/json" \
  -d '{"model":"power-ai","max_tokens":64,"messages":[{"role":"user","content":"Reply exactly OK."}]}'
Responses

Read text from output items containing output_text blocks. Response IDs and usage totals vary by request.

curl --fail-with-body --max-time 180 https://api.magnetapi.org/v1/responses \
  -H "Authorization: Bearer $API_KEY" \
  -H "Content-Type: application/json" \
  -d '{"model":"power-ai","input":"Reply exactly OK.","max_output_tokens":64}'
Anthropic-style Messages

Use /v1/messages and include the anthropic-version header. Read text blocks from content. No dashboard model change is needed when the request explicitly names power-ai.

curl --fail-with-body --max-time 180 https://api.magnetapi.org/v1/messages \
  -H "Authorization: Bearer $API_KEY" \
  -H "Content-Type: application/json" \
  -H "anthropic-version: 2023-06-01" \
  -d '{"model":"power-ai","max_tokens":64,"messages":[{"role":"user","content":"Reply exactly OK."}]}'
Streaming

This Responses example keeps the connection open for server-sent events. Handle text deltas, response.completed and error events; HTTP 200 alone does not prove a successful generation. Messages streams use content_block_delta and message_stop instead.

curl --fail-with-body --max-time 180 -N https://api.magnetapi.org/v1/responses \
  -H "Authorization: Bearer $API_KEY" \
  -H "Content-Type: application/json" \
  -d '{"model":"power-ai","input":"Reply exactly OK.","max_output_tokens":64,"stream":true}'
Function tools

Your application must execute get_project_name locally. Return a role=tool message with the matching tool_call_id after the complete assistant tool_calls message, then submit the conversation again. Do not omit a tool result or execute an unapproved function. Tools and images remain subject to the active destination's capabilities.

curl --fail-with-body --max-time 180 https://api.magnetapi.org/v1/chat/completions \
  -H "Authorization: Bearer $API_KEY" \
  -H "Content-Type: application/json" \
  -d '{"model":"power-ai","messages":[{"role":"user","content":"Use get_project_name to read the current project name."}],"tools":[{"type":"function","function":{"name":"get_project_name","description":"Read the name of the current project.","parameters":{"type":"object","properties":{},"additionalProperties":false}}}],"tool_choice":{"type":"function","function":{"name":"get_project_name"}},"max_tokens":256}'
Python

Python 3, standard library only. Set API_KEY in your environment. This sends one request and prints the answer and support request ID.

import json
import os
from urllib.request import Request, urlopen

payload = {'model': 'power-ai', 'max_tokens': 64, 'messages': [{'role': 'user', 'content': 'Reply exactly OK.'}]}
request = Request(
    "https://api.magnetapi.org/v1/chat/completions",
    data=json.dumps(payload).encode("utf-8"),
    headers={"Authorization": "Bearer " + os.environ["API_KEY"],
             "Content-Type": "application/json"},
    method="POST",
)
with urlopen(request, timeout=180) as response:
    result = json.load(response)
    print(result["choices"][0]["message"]["content"])
    print("Request ID:", response.headers.get("x-request-id", "not supplied"))
JavaScript / Node.js

Run with Node.js 18 or later. Keep the key on your server, never in public browser JavaScript. Set API_KEY before running the script.

async function main() {
  if (!process.env.API_KEY) throw new Error("Set API_KEY first");
  const response = await fetch("https://api.magnetapi.org/v1/chat/completions", {
    method: "POST",
    headers: {Authorization: `Bearer ${process.env.API_KEY}`, "Content-Type": "application/json"},
    body: JSON.stringify({"model": "power-ai", "max_tokens": 64, "messages": [{"role": "user", "content": "Reply exactly OK."}]}),
    signal: AbortSignal.timeout(180000),
  });
  const requestId = response.headers.get("x-request-id");
  if (!response.ok) throw new Error(`HTTP ${response.status}; request ID ${requestId}`);
  const result = await response.json();
  console.log(result.choices[0].message.content);
  console.log("Request ID:", requestId);
}
main().catch(error => { console.error(error.message); process.exitCode = 1; });
Windows PowerShell

Set the API_KEY environment variable to your own key, then paste this into PowerShell. This example does not overwrite any CLI configuration.

$ErrorActionPreference = 'Stop'
if (-not $env:API_KEY) { throw 'Set API_KEY first' }
$body = @{
  model = 'power-ai'
  max_tokens = 64
  messages = @(@{ role = 'user'; content = 'Reply exactly OK.' })
} | ConvertTo-Json -Depth 10
$result = Invoke-RestMethod -Method Post -Uri 'https://api.magnetapi.org/v1/chat/completions' -TimeoutSec 180 -Headers @{ Authorization = "Bearer $env:API_KEY" } -ContentType 'application/json' -Body $body
$result.choices[0].message.content

Troubleshooting

401: Check that the key belongs to this site and has not been revoked. 402: Check available wallet credit or matching Unlimited coverage. 403: Check key permissions and VIP entitlement if using VIP. 429: Respect Retry-After and avoid overlapping retries. 502/503: The current upstream could not complete the request; save the request ID for support. Do not resend a completed request blindly.

Image input uses OpenAI image_url blocks on Chat Completions and Anthropic image blocks on Messages. Never strip an image to make a request appear successful; verify support through the configured destination. Local file, shell and editor tools run in your client, not automatically on the API server.

API cost

10% of standard cost

All supported inference endpoints shown on this page are offered at 10% of the standard direct-provider cost.

Auth

Send your System Key or an active User API Key as a bearer token.


      

OpenAI-Compatible

Use Chat Completions or Responses-style routes for GPT-5.6 and compatible coding tools.


      

Claude-Compatible

Use Anthropic Messages routes for Claude Code clients and local coding tools.


      

Interactive API Request Builder

Select a public customer endpoint, review the JSON, and run a request using the key in the authorization bar. The builder never sends your key anywhere except https://api.magnetapi.org.

Ready
Response output and request-id diagnostics will appear here.

SDK Release Notes

v1.1.0 - 20 July 2026

v1.0.0 introduced the public Python and JavaScript clients with complete customer endpoint coverage and streaming helpers.

For support, include the request ID returned by the SDK or builder. Do not send your System Token.