# 开阳 Mizar > 开阳 Mizar is an OpenAI-compatible AI API relay: one endpoint, many upstream models, prepaid credits, pay-as-you-go. ## OpenAI Compatibility All endpoints follow the OpenAI API shape. Point any OpenAI SDK or tool at this site: - base_url: `https://app.mizarapi.com/v1` - api_key: create one in the console at `/keys` (sign in first), then send it as header `Authorization: Bearer sk-...` ## Endpoints - POST /v1/chat/completions — chat (supports stream=true, SSE) - POST /v1/images/generations — text-to-image (model names starting with mj- route to Midjourney; async jobs poll GET /v1/images/generations/{id}) - POST /v1/images/edits — image edit (multipart/form-data or JSON) - POST /v1/image-batches/generations — async image batch, up to 1000 images (Idempotency-Key honored; poll GET /v1/image-batches/{id}; billed per delivered image) - POST /v1/image-batches/edits — async image batch edit (public image URLs only) - POST /v1/embeddings — embeddings - POST /v1/moderations — moderation - POST /v1/rerank — rerank documents by query relevance - POST /v1/responses — OpenAI Responses API - POST /v1/videos — async video job; GET /v1/videos/{id} status; GET /v1/videos/{id}/content download; DELETE /v1/videos/{id} - POST /v1/cost-estimate — pre-flight cost estimation (read-only: no billing, no ledger; shares key rate limits) - GET /v1/models — list available models - Gemini native: POST /v1beta/models/{model}:generateContent (and :streamGenerateContent for SSE, :countTokens non-billed passthrough); GET /v1beta/models lists models - Interactions (background-jobs style): POST /v1beta/interactions; GET/DELETE /v1beta/interactions/{id} - Midjourney native: POST /mj/submit/{command} (imagine/upscale/variation/reroll/blend/describe/modal/video/edit...); POST /mj/insight-face/swap; GET /mj/task/{id}/fetch; GET /mj/task/{id}/image (302 to asset); POST /mj/task/url/refresh ## Pricing GET /api/pricing (anonymous JSON) returns per-model prices: - `quota_type=0` token-based: `model_ratio` (input), `completion_ratio` (output/input), `cache_ratio` (cached read/input), `create_cache_ratio` (cache write/input). Conversions: $/1M tokens = model_ratio x 2; credits/1M tokens = model_ratio x 2,000,000 (1 USD = 1,000,000 credits). - `quota_type=1` per-request: `model_price` is USD per request. Example: {"success":true,"data":[{"model_name":"gpt-4o-mini","quota_type":0,"model_ratio":0.075,"completion_ratio":4}]} ## Quick Start (curl) Chat, non-streaming: curl https://app.mizarapi.com/v1/chat/completions \ -H "Authorization: Bearer sk-..." \ -H "Content-Type: application/json" \ -d '{"model":"gpt-4o-mini","messages":[{"role":"user","content":"Hello"}]}' Chat, streaming (SSE): curl https://app.mizarapi.com/v1/chat/completions \ -H "Authorization: Bearer sk-..." \ -H "Content-Type: application/json" \ -d '{"model":"gpt-4o-mini","stream":true,"messages":[{"role":"user","content":"Hello"}]}' ## API Reference Full machine-readable spec: GET /openapi.json (OpenAPI 3.1; paste into https://editor.swagger.io to explore and generate clients). ## MCP MCP server (Model Context Protocol) at `POST https://app.mizarapi.com/mcp` — JSON-RPC 2.0 over Streamable HTTP, single response (no SSE push), batch (array) requests not supported, protocolVersion 2025-03-26. - Auth: the same API key (`Authorization: Bearer sk-...`), required for every message including initialize - Tools: list_models / query_balance / chat_completion (non-streaming; rejects stream=true — use /v1 for SSE) / generate_image / trace_detail (query one of your own past requests by request_id; others' or unknown ids return not_found) / recent_errors (aggregate your own failed requests by error_code over a lookback window, default 24h). Chat and image calls run the same billing pipeline as /v1. Initialize: curl https://app.mizarapi.com/mcp \ -H "Authorization: Bearer sk-..." \ -H "Content-Type: application/json" \ -d '{"jsonrpc":"2.0","id":1,"method":"initialize","params":{"protocolVersion":"2025-03-26","capabilities":{},"clientInfo":{"name":"demo","version":"1.0"}}}' Call a tool (chat_completion): curl https://app.mizarapi.com/mcp \ -H "Authorization: Bearer sk-..." \ -H "Content-Type: application/json" \ -d '{"jsonrpc":"2.0","id":2,"method":"tools/call","params":{"name":"chat_completion","arguments":{"model":"gpt-4o-mini","messages":[{"role":"user","content":"Hello"}]}}}'