{"openapi":"3.1.0","info":{"title":"MagnetAPI.org OpenAI and Anthropic Compatible API","description":"Customer inference API compatible with the OpenAI Responses, Chat Completions, legacy Completions, and Models interfaces plus Anthropic Messages, token counting, and Models. For the supported endpoints shown here, MagnetAPI advertises usage at 10% of the standard direct-provider cost. Replace the provider base URL with https://api.magnetapi.org and use your MagnetAPI System Key or a User API Key created in the dashboard. Provider organization administration, training, media generation, and provider-hosted storage products are outside this coding-model API. Admin endpoints are never included in this public schema.","version":"1.0.0"},"paths":{"/api/health":{"get":{"summary":"Health","operationId":"health_api_health_get","responses":{"200":{"description":"Successful Response","content":{"application/json":{"schema":{"additionalProperties":true,"type":"object","title":"Response Health Api Health Get"}}}}},"description":"Checks whether the MagnetAPI customer API is reachable. This route does not require a key and does not consume wallet credit."}},"/api/v1/auth/login":{"post":{"summary":"Api V1 Login","operationId":"api_v1_login_api_v1_auth_login_post","requestBody":{"content":{"application/json":{"schema":{"$ref":"#/components/schemas/LoginBody"}}},"required":true},"responses":{"200":{"description":"Successful Response","content":{"application/json":{"schema":{"additionalProperties":true,"type":"object","title":"Response Api V1 Login Api V1 Auth Login Post"}}}},"422":{"description":"Validation Error","content":{"application/json":{"schema":{"$ref":"#/components/schemas/HTTPValidationError"}}}}},"description":"Signs in with a MagnetAPI dashboard username or saved email address and password. Use the returned dashboard session only for account pages; use the System Key or a User API Key for model requests."}},"/api/v1/me":{"get":{"summary":"Api V1 Me","operationId":"api_v1_me_api_v1_me_get","responses":{"200":{"description":"Successful Response","content":{"application/json":{"schema":{"additionalProperties":true,"type":"object","title":"Response Api V1 Me Api V1 Me Get"}}}}},"description":"Returns the account and credential type associated with the supplied bearer key. A User API Key never returns the permanent System Key or personalized setup credentials.","security":[{"MagnetApiBearer":[]}]}},"/api/v1/model":{"get":{"tags":["account"],"summary":"Read the default model selected for this API account","description":"Returns the account-level default used when a compatible inference request omits `model`. A request-level `model` field always takes precedence.","operationId":"api_v1_model_preference_api_v1_model_get","responses":{"200":{"description":"Successful Response","content":{"application/json":{"schema":{"additionalProperties":true,"type":"object","title":"Response Api V1 Model Preference Api V1 Model Get"}}}}},"security":[{"MagnetApiBearer":[]}]},"put":{"tags":["account"],"summary":"Set the default model for this API account","description":"Sets the account-level default model. This is useful for SDKs that omit `model`; callers can still select a different supported model in each inference request.","operationId":"api_v1_set_model_preference_api_v1_model_put","requestBody":{"content":{"application/json":{"schema":{"$ref":"#/components/schemas/ModelPreferenceBody"}}},"required":true},"responses":{"200":{"description":"Successful Response","content":{"application/json":{"schema":{"additionalProperties":true,"type":"object","title":"Response Api V1 Set Model Preference Api V1 Model Put"}}}},"422":{"description":"Validation Error","content":{"application/json":{"schema":{"$ref":"#/components/schemas/HTTPValidationError"}}}}},"security":[{"MagnetApiBearer":[]}]}},"/api/v1/vip":{"get":{"summary":"Api V1 Vip","operationId":"api_v1_vip_api_v1_vip_get","responses":{"200":{"description":"Successful Response","content":{"application/json":{"schema":{"additionalProperties":true,"type":"object","title":"Response Api V1 Vip Api V1 Vip Get"}}}}},"description":"Returns the current VIP entitlement, remaining access time, and VIP setup information for the authenticated account.","security":[{"MagnetApiBearer":[]}]}},"/api/v1/wallet/status":{"get":{"summary":"Api V1 Wallet Status","operationId":"api_v1_wallet_status_api_v1_wallet_status_get","responses":{"200":{"description":"Successful Response","content":{"application/json":{"schema":{"additionalProperties":true,"type":"object","title":"Response Api V1 Wallet Status Api V1 Wallet Status Get"}}}}},"description":"Returns the current API Coding Credit balance and active access state without making a model request or charging the wallet.","security":[{"MagnetApiBearer":[]}]}},"/api/v1/billing/token-usage":{"get":{"summary":"Api V1 Token Usage","operationId":"api_v1_token_usage_api_v1_billing_token_usage_get","responses":{"200":{"description":"Successful Response","content":{"application/json":{"schema":{"additionalProperties":true,"type":"object","title":"Response Api V1 Token Usage Api V1 Billing Token Usage Get"}}}}},"description":"Returns the authenticated account's recent token usage and wallet deductions using the same live internal token rates applied to System Keys and User API Keys.","security":[{"MagnetApiBearer":[]}]}},"/v1/models":{"get":{"tags":["models"],"summary":"List models using the OpenAI or Anthropic wire format","description":"Returns an OpenAI `object: list` response by default. Requests carrying `anthropic-version` receive Anthropic pagination fields and model capability descriptors.\n\nPower 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.","operationId":"models_v1_models_get","responses":{"200":{"description":"Successful Response","content":{"application/json":{"schema":{"additionalProperties":true,"type":"object","title":"Response Models V1 Models Get"}}}}},"security":[{"MagnetApiBearer":[]}]}},"/v1/models/{model_id}":{"get":{"tags":["models"],"summary":"Retrieve one model descriptor","description":"Uses OpenAI or Anthropic response fields according to the request headers.","operationId":"retrieve_model_v1_models__model_id__get","parameters":[{"name":"model_id","in":"path","required":true,"schema":{"type":"string","title":"Model Id"}}],"responses":{"200":{"description":"Successful Response","content":{"application/json":{"schema":{"type":"object","additionalProperties":true,"title":"Response Retrieve Model V1 Models  Model Id  Get"}}}},"422":{"description":"Validation Error","content":{"application/json":{"schema":{"$ref":"#/components/schemas/HTTPValidationError"}}}}},"security":[{"MagnetApiBearer":[]}]}},"/v1/responses":{"post":{"tags":["openai-responses"],"summary":"Create an OpenAI-compatible model response","description":"Accepts text, image inputs, instructions, custom function tools, tool results, structured output settings, metadata, and streaming. Select a supported model with the request `model` field.\n\nPower 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.","operationId":"responses_proxy_v1_responses_post","responses":{"200":{"description":"Successful Response","content":{"application/json":{"schema":{}}}}},"security":[{"MagnetApiBearer":[]}],"requestBody":{"content":{"application/json":{"schema":{"type":"object","additionalProperties":true},"examples":{"power_ai":{"summary":"Power AI - a first request","value":{"model":"power-ai","input":"Reply exactly OK.","max_output_tokens":64}},"power_ai_stream":{"summary":"Power AI - streaming","value":{"model":"power-ai","input":"Reply exactly OK.","max_output_tokens":64,"stream":true}}}}}}}},"/v1/responses/input_tokens":{"post":{"tags":["openai-responses"],"summary":"Count input tokens for a Responses request","description":"Returns the estimated input token count without generating or billing a model response.","operationId":"responses_input_tokens_v1_responses_input_tokens_post","responses":{"200":{"description":"Successful Response","content":{"application/json":{"schema":{"additionalProperties":true,"type":"object","title":"Response Responses Input Tokens V1 Responses Input Tokens Post"}}}}},"security":[{"MagnetApiBearer":[]}]}},"/v1/responses/count_tokens":{"post":{"tags":["openai-responses"],"summary":"Count input tokens for a Responses request","description":"Compatibility alias for `/v1/responses/input_tokens`.","operationId":"responses_count_tokens_v1_responses_count_tokens_post","responses":{"200":{"description":"Successful Response","content":{"application/json":{"schema":{"additionalProperties":true,"type":"object","title":"Response Responses Count Tokens V1 Responses Count Tokens Post"}}}}},"security":[{"MagnetApiBearer":[]}]}},"/v1/responses/compact":{"post":{"tags":["openai-responses"],"summary":"Compact conversation input for a later Responses call","description":"Returns an OpenAI-shaped `response.compaction` object. Pass the returned `output` items as the input to a later MagnetAPI Responses request.","operationId":"compact_response_input_v1_responses_compact_post","responses":{"200":{"description":"Successful Response","content":{"application/json":{"schema":{"additionalProperties":true,"type":"object","title":"Response Compact Response Input V1 Responses Compact Post"}}}}},"security":[{"MagnetApiBearer":[]}]}},"/v1/responses/{response_id}":{"get":{"tags":["openai-responses"],"summary":"Retrieve a stored response","operationId":"retrieve_response_v1_responses__response_id__get","parameters":[{"name":"response_id","in":"path","required":true,"schema":{"type":"string","title":"Response Id"}}],"responses":{"200":{"description":"Successful Response","content":{"application/json":{"schema":{"type":"object","additionalProperties":true,"title":"Response Retrieve Response V1 Responses  Response Id  Get"}}}},"422":{"description":"Validation Error","content":{"application/json":{"schema":{"$ref":"#/components/schemas/HTTPValidationError"}}}}},"description":"Retrieves a Responses API object previously stored for this MagnetAPI account. The response id must belong to the authenticated account.","security":[{"MagnetApiBearer":[]}]},"delete":{"tags":["openai-responses"],"summary":"Delete a stored response","operationId":"delete_response_v1_responses__response_id__delete","parameters":[{"name":"response_id","in":"path","required":true,"schema":{"type":"string","title":"Response Id"}}],"responses":{"200":{"description":"Successful Response","content":{"application/json":{"schema":{"type":"object","additionalProperties":true,"title":"Response Delete Response V1 Responses  Response Id  Delete"}}}},"422":{"description":"Validation Error","content":{"application/json":{"schema":{"$ref":"#/components/schemas/HTTPValidationError"}}}}},"description":"Deletes a stored Responses API object owned by the authenticated account. This removes the stored object but does not reverse completed model usage.","security":[{"MagnetApiBearer":[]}]}},"/v1/responses/{response_id}/input_items":{"get":{"tags":["openai-responses"],"summary":"List input items for a stored response","operationId":"response_input_items_v1_responses__response_id__input_items_get","parameters":[{"name":"response_id","in":"path","required":true,"schema":{"type":"string","title":"Response Id"}}],"responses":{"200":{"description":"Successful Response","content":{"application/json":{"schema":{"type":"object","additionalProperties":true,"title":"Response Response Input Items V1 Responses  Response Id  Input Items Get"}}}},"422":{"description":"Validation Error","content":{"application/json":{"schema":{"$ref":"#/components/schemas/HTTPValidationError"}}}}},"description":"Lists the input items captured for a stored Responses API object so an integration can reconstruct the request context.","security":[{"MagnetApiBearer":[]}]}},"/v1/responses/{response_id}/cancel":{"post":{"tags":["openai-responses"],"summary":"Cancel a stored response if it is still in progress","operationId":"cancel_response_v1_responses__response_id__cancel_post","parameters":[{"name":"response_id","in":"path","required":true,"schema":{"type":"string","title":"Response Id"}}],"responses":{"200":{"description":"Successful Response","content":{"application/json":{"schema":{"type":"object","additionalProperties":true,"title":"Response Cancel Response V1 Responses  Response Id  Cancel Post"}}}},"422":{"description":"Validation Error","content":{"application/json":{"schema":{"$ref":"#/components/schemas/HTTPValidationError"}}}}},"description":"Requests cancellation of a stored response that is still in progress. Completed responses cannot be cancelled or refunded by this lifecycle call.","security":[{"MagnetApiBearer":[]}]}},"/v1/responses/{response_id}/compact":{"post":{"tags":["openai-responses"],"summary":"Compact the input captured for a stored response","operationId":"compact_stored_response_v1_responses__response_id__compact_post","parameters":[{"name":"response_id","in":"path","required":true,"schema":{"type":"string","title":"Response Id"}}],"responses":{"200":{"description":"Successful Response","content":{"application/json":{"schema":{"type":"object","additionalProperties":true,"title":"Response Compact Stored Response V1 Responses  Response Id  Compact Post"}}}},"422":{"description":"Validation Error","content":{"application/json":{"schema":{"$ref":"#/components/schemas/HTTPValidationError"}}}}},"description":"Creates a compact context object from the stored response input for reuse in a later Responses API request.","security":[{"MagnetApiBearer":[]}]}},"/v1/messages":{"post":{"tags":["anthropic-messages"],"summary":"Create an Anthropic-compatible Message","description":"Supports Anthropic Messages request and response shapes, streaming SSE, system prompts, images, documents, tool schemas, tool choice, tool results, prompt caching fields, and token usage.\n\nPower 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.","operationId":"claude_messages_v1_messages_post","responses":{"200":{"description":"Successful Response","content":{"application/json":{"schema":{}}}}},"security":[{"MagnetApiBearer":[]}],"requestBody":{"content":{"application/json":{"schema":{"type":"object","additionalProperties":true},"examples":{"power_ai":{"summary":"Power AI - a first request","value":{"model":"power-ai","max_tokens":64,"messages":[{"role":"user","content":"Reply exactly OK."}]}},"power_ai_stream":{"summary":"Power AI - streaming","value":{"model":"power-ai","max_tokens":64,"messages":[{"role":"user","content":"Reply exactly OK."}],"stream":true}}}}}},"parameters":[{"in":"header","name":"anthropic-version","required":false,"schema":{"type":"string","default":"2023-06-01"}}]}},"/v1/messages/{subpath}":{"post":{"tags":["anthropic-messages"],"summary":"Anthropic Messages helper endpoint","description":"Use subpath `count_tokens` to estimate Anthropic message input tokens. Other supported Messages subpaths are forwarded through the same authenticated model gateway.","operationId":"claude_messages_subpath_v1_messages__subpath__post","parameters":[{"name":"subpath","in":"path","required":true,"schema":{"type":"string","title":"Subpath"}}],"responses":{"200":{"description":"Successful Response","content":{"application/json":{"schema":{}}}},"422":{"description":"Validation Error","content":{"application/json":{"schema":{"$ref":"#/components/schemas/HTTPValidationError"}}}}},"security":[{"MagnetApiBearer":[]}]}},"/v1/chat/completions":{"get":{"tags":["openai-chat"],"summary":"List stored Chat Completions","operationId":"list_chat_completions_v1_chat_completions_get","responses":{"200":{"description":"Successful Response","content":{"application/json":{"schema":{"additionalProperties":true,"type":"object","title":"Response List Chat Completions V1 Chat Completions Get"}}}}},"description":"Lists stored Chat Completions owned by the authenticated account. Use pagination query parameters when they are shown in the schema.","security":[{"MagnetApiBearer":[]}]},"post":{"tags":["openai-chat"],"summary":"Create an OpenAI-compatible Chat Completion","description":"Accepts OpenAI chat messages, developer/system messages, image content, custom function tools, tool results, metadata, and streaming. Set `store: true` to enable retrieval endpoints.\n\nPower 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.","operationId":"chat_completions_proxy_v1_chat_completions_post","responses":{"200":{"description":"Successful Response","content":{"application/json":{"schema":{}}}}},"security":[{"MagnetApiBearer":[]}],"requestBody":{"content":{"application/json":{"schema":{"type":"object","additionalProperties":true},"examples":{"power_ai":{"summary":"Power AI - a first request","value":{"model":"power-ai","max_tokens":64,"messages":[{"role":"user","content":"Reply exactly OK."}]}},"power_ai_stream":{"summary":"Power AI - streaming","value":{"model":"power-ai","max_tokens":64,"messages":[{"role":"user","content":"Reply exactly OK."}],"stream":true}},"power_ai_tool":{"summary":"Power AI - local function call","value":{"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}}}}}}}},"/v1/chat/completions/{completion_id}":{"get":{"tags":["openai-chat"],"summary":"Retrieve a stored Chat Completion","operationId":"retrieve_chat_completion_v1_chat_completions__completion_id__get","parameters":[{"name":"completion_id","in":"path","required":true,"schema":{"type":"string","title":"Completion Id"}}],"responses":{"200":{"description":"Successful Response","content":{"application/json":{"schema":{"type":"object","additionalProperties":true,"title":"Response Retrieve Chat Completion V1 Chat Completions  Completion Id  Get"}}}},"422":{"description":"Validation Error","content":{"application/json":{"schema":{"$ref":"#/components/schemas/HTTPValidationError"}}}}},"description":"Retrieves one stored Chat Completion owned by the authenticated account.","security":[{"MagnetApiBearer":[]}]},"patch":{"tags":["openai-chat"],"summary":"Update stored Chat Completion metadata","operationId":"update_chat_completion_v1_chat_completions__completion_id__patch","parameters":[{"name":"completion_id","in":"path","required":true,"schema":{"type":"string","title":"Completion Id"}}],"responses":{"200":{"description":"Successful Response","content":{"application/json":{"schema":{"type":"object","additionalProperties":true,"title":"Response Update Chat Completion V1 Chat Completions  Completion Id  Patch"}}}},"422":{"description":"Validation Error","content":{"application/json":{"schema":{"$ref":"#/components/schemas/HTTPValidationError"}}}}},"description":"Updates supported metadata on a stored Chat Completion. This does not rerun the model or alter the original billed generation.","security":[{"MagnetApiBearer":[]}]},"delete":{"tags":["openai-chat"],"summary":"Delete a stored Chat Completion","operationId":"delete_chat_completion_v1_chat_completions__completion_id__delete","parameters":[{"name":"completion_id","in":"path","required":true,"schema":{"type":"string","title":"Completion Id"}}],"responses":{"200":{"description":"Successful Response","content":{"application/json":{"schema":{"type":"object","additionalProperties":true,"title":"Response Delete Chat Completion V1 Chat Completions  Completion Id  Delete"}}}},"422":{"description":"Validation Error","content":{"application/json":{"schema":{"$ref":"#/components/schemas/HTTPValidationError"}}}}},"description":"Deletes a stored Chat Completion owned by the authenticated account. Completed usage remains in the account ledger.","security":[{"MagnetApiBearer":[]}]}},"/v1/chat/completions/{completion_id}/messages":{"get":{"tags":["openai-chat"],"summary":"List messages captured for a stored Chat Completion","operationId":"chat_completion_messages_v1_chat_completions__completion_id__messages_get","parameters":[{"name":"completion_id","in":"path","required":true,"schema":{"type":"string","title":"Completion Id"}}],"responses":{"200":{"description":"Successful Response","content":{"application/json":{"schema":{"type":"object","additionalProperties":true,"title":"Response Chat Completion Messages V1 Chat Completions  Completion Id  Messages Get"}}}},"422":{"description":"Validation Error","content":{"application/json":{"schema":{"$ref":"#/components/schemas/HTTPValidationError"}}}}},"description":"Lists the messages captured for a stored Chat Completion so an integration can review the saved conversation payload.","security":[{"MagnetApiBearer":[]}]}},"/v1/completions":{"post":{"tags":["openai-completions"],"summary":"Create a legacy OpenAI-compatible text completion","description":"Adapts legacy prompt-based clients to the same wallet-backed model gateway.","operationId":"legacy_completions_v1_completions_post","responses":{"200":{"description":"Successful Response","content":{"application/json":{"schema":{}}}}},"security":[{"MagnetApiBearer":[]}]}}},"components":{"schemas":{"HTTPValidationError":{"properties":{"detail":{"items":{"$ref":"#/components/schemas/ValidationError"},"type":"array","title":"Detail"}},"type":"object","title":"HTTPValidationError"},"LoginBody":{"properties":{"username":{"type":"string","title":"Username"},"password":{"type":"string","title":"Password"}},"type":"object","required":["username","password"],"title":"LoginBody"},"ModelPreferenceBody":{"properties":{"model":{"type":"string","title":"Model"}},"type":"object","required":["model"],"title":"ModelPreferenceBody"},"ValidationError":{"properties":{"loc":{"items":{"anyOf":[{"type":"string"},{"type":"integer"}]},"type":"array","title":"Location"},"msg":{"type":"string","title":"Message"},"type":{"type":"string","title":"Error Type"},"input":{"title":"Input"},"ctx":{"type":"object","title":"Context"}},"type":"object","required":["loc","msg","type"],"title":"ValidationError"}},"securitySchemes":{"MagnetApiBearer":{"type":"http","scheme":"bearer","bearerFormat":"MagnetAPI System Key or User API Key","description":"Use the permanent MagnetAPI System Key or any active User API Key created in the dashboard."}}},"servers":[{"url":"https://api.magnetapi.org","description":"MagnetAPI.org production API"}]}