### Install Sofya MCP plugin for Claude Code Source: https://sofya.co/docs Install the Sofya MCP plugin which adds the server plus skills that guide when to use search, fetch, extract, or research. ```bash /plugin marketplace add sofya-co/sofya-mcp /plugin install sofya@sofya ``` -------------------------------- ### Fetch API Usage Examples (curl, Python, JavaScript) Source: https://sofya.co/docs Client examples for POST /v1/fetch across three languages. The curl example uses `-X POST` with a JSON body; the Python example uses `httpx.post` with a 90-second timeout; the JavaScript example uses `fetch` and requires Node 18+ (save as example.mjs for top-level await). ```bash curl -X POST https://sofya.co/v1/fetch \ -H "Content-Type: application/json" \ -H "Authorization: Bearer sofya_live_..." \ -d '{"urls": ["https://example.com"]}' ``` ```python import httpx resp = httpx.post("https://sofya.co/v1/fetch", headers={"Authorization": "Bearer sofya_live_..."}, json={"urls": ["https://example.com"]}, timeout=90) print(resp.json()) ``` ```javascript // Node 18+: save as example.mjs (top-level await needs a module) const resp = await fetch("https://sofya.co/v1/fetch", { method: "POST", headers: { "Content-Type": "application/json", "Authorization": "Bearer sofya_live_..." }, body: JSON.stringify({ urls: ["https://example.com"] }) }); console.log(await resp.json()); ``` -------------------------------- ### Search examples (curl, Python, JavaScript) Source: https://sofya.co/docs Example calls to POST /v1/search using curl, Python with httpx, and Node.js fetch. Each sends a basic query for latest AI news. ```bash curl -X POST https://sofya.co/v1/search \ -H "Content-Type: application/json" \ -H "Authorization: Bearer sofya_live_..." \ -d '{"query": "latest AI news", "search_depth": "basic"}' ``` ```python import httpx resp = httpx.post("https://sofya.co/v1/search", headers={"Authorization": "Bearer sofya_live_..."}, json={"query": "latest AI news", "search_depth": "basic"}, timeout=90) # longer than the server's limit, so you get its answer or error print(resp.json()) ``` ```javascript // Node 18+: save as example.mjs (top-level await needs a module) const resp = await fetch("https://sofya.co/v1/search", { method: "POST", headers: { "Content-Type": "application/json", "Authorization": "Bearer sofya_live_..." }, body: JSON.stringify({ query: "latest AI news", search_depth: "basic" }) }); console.log(await resp.json()); ``` -------------------------------- ### Start signup: POST /v1/agent/signup Source: https://sofya.co/auth Starts an API key request. Returns a claim token and user code. Both fields are optional; add "amount_usd" to also request credits in the same visit. ```http POST https://sofya.co/v1/agent/signup Content-Type: application/json {"client_name": "Your agent's name", "login_hint": "user@example.com"} ``` -------------------------------- ### Usage response JSON example Source: https://sofya.co/llms-full.txt Shows the 200 response for GET /v1/auth/usage. Rows are per day, endpoint, and API key, newest day first; api_key_id and api_key_name are null for rows not tied to a key. ```json [ { "date": "2026-10-08", "endpoint": "/v1/search", "request_count": 3, "total_credits": 6, "api_key_id": "4505fa6c-edff-eff6-7aa9-547504df43ee", "api_key_name": "Production" } ] ``` -------------------------------- ### Install Sofya plugin (Claude Code) Source: https://sofya.co/llms-full.txt Adds the Sofya marketplace plugin and installs the sofya plugin, which adds the MCP server plus two skills that guide when to search, fetch, extract, or research. ```plaintext /plugin marketplace add sofya-co/sofya-mcp /plugin install sofya@sofya ``` -------------------------------- ### Install Sofya skills via npx Source: https://sofya.co/llms-full.txt Installs Sofya skills for agents like Claude Code, Cursor, Codex, and Gemini CLI. They use MCP tools when connected, otherwise the REST API with SOFYA_API_KEY. ```bash npx skills add sofya-co/sofya-mcp ``` -------------------------------- ### Search response JSON example Source: https://sofya.co/llms-full.txt Example response for a successful search request. Shows the structure with query, results, credits_used, and credits_remaining. ```json { "query": "latest AI news", "results": [ { "title": "...", "url": "https://...", "content": "Extracted page text...", "published_date": "2026-10-27" } ], "credits_used": 2, "credits_remaining": 1998 } ``` -------------------------------- ### Codex MCP CLI setup for Sofya Source: https://sofya.co/llms-full.txt Configure Sofya MCP server in Codex using sign-in flow. ```bash codex mcp add sofya --url https://mcp.sofya.co/mcp codex mcp login sofya ``` -------------------------------- ### GET /v1/auth/me Source: https://sofya.co/llms-full.txt Get your account info: credit balance, tier and total requests. Free. ```APIDOC ## GET /v1/auth/me ### Description Get your account info: credit balance, tier and total requests. Free. ### Method GET ### Endpoint /v1/auth/me ### Response #### Success Response (200) - **credits** (integer) - Total spendable balance, `plan_credits` (free-tier credits) plus `purchased_credits`. - **plan_credits** (integer) - Free-tier credits. - **purchased_credits** (integer) - Purchased credits. - **is_free_tier** (boolean) - Whether the account is on the free tier. - **credits_reset_at** (string) - When free-tier credits next reset to 2,000 (every 30 days). Purchased credits never reset. - **total_requests** (integer) - Total number of requests made. - **api_key** (string or null) - Always null, unless the signed-in dashboard asks for it. - **last_login_method** (string) - Method used for last login. - **email** (string) - User's email address. - **email_verified** (boolean) - Whether the email is verified. - **github_username** (string) - GitHub username. - **has_billing_portal** (boolean) - Whether the user has a billing portal. - **new_ip_alerts_enabled** (boolean) - Whether new IP alerts are enabled. - **low_balance_alerts_enabled** (boolean) - Whether low balance alerts are enabled. - **low_balance_threshold** (integer or null) - Low balance threshold. - **low_balance_threshold_auto** (integer) - Auto low balance threshold. #### Response Example ```json { "credits": 1994, "plan_credits": 1994, "purchased_credits": 0, "is_free_tier": true, "credits_reset_at": "2026-11-04T12:00:00Z", "total_requests": 3, "api_key": null, "last_login_method": "github", "email": "user@example.com", "email_verified": true, "github_username": "octocat", "has_billing_portal": false, "new_ip_alerts_enabled": true, "low_balance_alerts_enabled": true, "low_balance_threshold": null, "low_balance_threshold_auto": 1000 } ``` ``` -------------------------------- ### GET /v1/status response example Source: https://sofya.co/llms-full.txt Shows the 200 response for GET /v1/status (no API key). Reports health of search, fetch, extract, research, and mcp endpoints; latency_ms may be null, and is always null for mcp. ```json { "overall": "operational", "endpoints": { "search": { "status": "operational", "latency_ms": 1905.9, "last_check": "2026-10-09T14:00:27+00:00" }, "fetch": { "status": "operational", "latency_ms": 4116.3, "last_check": "2026-10-09T13:59:47+00:00" }, "extract": { "status": "operational", "latency_ms": 14693.6, "last_check": "2026-10-09T13:59:18+00:00" }, "research": { "status": "operational", "latency_ms": 17904.2, "last_check": "2026-10-09T13:59:18+00:00" }, "mcp": { "status": "operational", "latency_ms": null, "last_check": "2026-10-09T13:58:41+00:00" } }, "incidents": [] } ``` -------------------------------- ### POST /v1/agent/signup Source: https://sofya.co/docs Initiates the agent sign-up flow for agents without an API key to get one, with user approval. Required for agents to obtain credentials. ```APIDOC ## POST /v1/agent/signup ### Description Initiates the agent sign-up flow for agents without an API key to get one, with user approval. Required for agents to obtain credentials. ### Method POST ### Endpoint `/v1/agent/signup` ### Parameters #### Request Body - `client_name` (string) - Optional - Name shown to the approver on the approval page. - `login_hint` (string) - Optional - Email the agent expects the approver to use. - `amount_usd` (integer) - Optional - Whole US dollars from $10 to $25,000 to request credits in the same visit. ### Response #### Success Response (200) - `claim_token` (string) - Token used to poll for the API key. - `user_code` (string) - User code for the approval flow. - `verification_uri` (string) - URI for the approval page. - `verification_uri_complete` (string) - URI with the code embedded. - `expires_in` (integer) - Seconds until the token expires. - `interval` (integer) - Polling interval in seconds. - `token_endpoint` (string) - Endpoint to poll for the token. - `message` (string) - Message from the server. - `claim` (object) - Repeat of claim_token. - `device_code` (string) - Device code for OAuth device flow. - `credits` (integer) - Credits bought with amount_usd. ### Request Example ``` curl -X POST https://sofya.co/v1/agent/signup \ -H "Content-Type: application/json" \ -d '{"client_name": "My agent", "login_hint": "you@example.com"}' ``` #### Response Example ```json { "claim_token": "clm_...", "user_code": "BCDF-GHJK", "verification_uri": "https://sofya.co/device", "verification_uri_complete": "https://sofya.co/device?code=BCDF-GHJK", "expires_in": 1800, "interval": 5, "token_endpoint": "https://sofya.co/v1/agent/token", "message": "..." } ``` ``` -------------------------------- ### JavaScript example - fetch POST /v1/search Source: https://sofya.co/llms-full.txt JavaScript code using fetch to call the Search API. Node 18+ and a module file (e.g., example.mjs) are needed for top-level await. Prints the JSON response. ```javascript // Node 18+: save as example.mjs (top-level await needs a module) const resp = await fetch("https://sofya.co/v1/search", { method: "POST", headers: { "Content-Type": "application/json", "Authorization": "Bearer sofya_live_..." }, body: JSON.stringify({ query: "latest AI news", search_depth: "basic" }) }); console.log(await resp.json()); ``` -------------------------------- ### POST /v1/agent/signup Source: https://sofya.co/auth Starts the API key request flow. It initiates a signup request that requires human approval, and returns a claim token and verification URI to present to the user. ```APIDOC ## [POST] /v1/agent/signup ### Description Starts the API key request flow. It initiates a signup request that requires human approval, and returns a claim token and verification URI to present to the user. ### Method POST ### Endpoint https://sofya.co/v1/agent/signup ### Parameters #### Request Body - **client_name** (string) - Optional - Name of the agent shown to the person. - **login_hint** (string) - Optional - Email expected for the person approving. - **amount_usd** (integer) - Optional - Whole US dollars from 10 to 25,000 to buy credits in the same visit. One dollar buys 400 credits. ### Response #### Success Response (200) - **claim_token** (string) - Token to poll for approval. - **user_code** (string) - Human-readable code for the user to verify. - **verification_uri** (string) - URI to open for approval. - **verification_uri_complete** (string) - URI including the code, e.g., https://sofya.co/device?code=BCDF-GHJK. - **expires_in** (number) - Expiration time in seconds. - **interval** (number) - Polling interval in seconds. - **token_endpoint** (string) - URL to poll for approval. - **claim** (object) - Same values nested, including device_code. - **device_code** (string) - Device code for OAuth device flow. - **amount_usd** (integer) - Required if sent, repeated in response. - **credits** (integer) - Credits purchased by amount_usd. #### Error Response (400) - **error** (string) - `invalid_request` when amount_usd is not whole dollars within 10-25,000. - **error** (string) - `slow_down` when too many signups from one address in an hour. ``` -------------------------------- ### GET /v1/billing/topup (pay_url) - Payment Flow Source: https://sofya.co/auth Describes the process of using a pay_url to make a payment via the Machine Payments Protocol (MPP). The pay_url is obtained from topup or balance responses, and can be called with GET or POST. ```APIDOC ## GET /v1/billing/topup (pay_url) - Payment Flow ### Description Handles payment via an MPP-compatible wallet using the pay_url. The flow involves receiving a 402 challenge, submitting payment proof, and receiving confirmation. ### Method GET or POST ### Endpoint (The pay_url from topup, balance, or a 402 response) ### Notes - The pay_url is for wallets only; use `checkout_url` for humans. - The link requires no API key and works for 24 hours. - If payment is initiated, pay within 10 minutes. - A `503` indicates the payment may have gone through; do not pay again—resend the same request after `Retry-After` seconds. ### Request - Call the pay_url with `GET` or `POST`. - First call returns `402` with a `WWW-Authenticate: Payment` challenge. - After paying, call again with the proof in the `Authorization: Payment ...` header. ### Response #### Success Response (200) - `status` - Set to `credited`. - `amount_usd` - The amount paid in USD. - `credits_added` - Number of credits added. - `credits` - New total credits after the payment. #### Duplicate Proof (200) - `already_credited` - Indicates the payment was already processed safely. #### Payment Pending (503) - The payment may have gone through; retry after `Retry-After` seconds. ``` -------------------------------- ### Research via JavaScript (fetch) Source: https://sofya.co/llms-full.txt Node 18+ example using fetch with top-level await; save as example.mjs. Sends a POST request to /v1/research. ```javascript // Node 18+: save as example.mjs (top-level await needs a module) const resp = await fetch("https://sofya.co/v1/research", { method: "POST", headers: { "Content-Type": "application/json", "Authorization": "Bearer sofya_live_..." }, body: JSON.stringify({ query: "How do modern LLMs handle long context?" }) }); console.log(await resp.json()); ``` -------------------------------- ### Fetch with Python (httpx) Source: https://sofya.co/llms-full.txt Python example using the httpx library to call the Fetch API. Sends the URL list as JSON and prints the response. The timeout is set to 90 seconds. ```python import httpx resp = httpx.post("https://sofya.co/v1/fetch", headers={"Authorization": "Bearer sofya_live_..."}, json={"urls": ["https://example.com"]}, timeout=90) print(resp.json()) ``` -------------------------------- ### Fetch with JavaScript (Node 18+) Source: https://sofya.co/llms-full.txt JavaScript example using the global fetch API (Node 18+). Save as example.mjs because top-level await requires a module. Sends a POST request to the Fetch API and logs the JSON response. ```javascript // Node 18+: save as example.mjs (top-level await needs a module) const resp = await fetch("https://sofya.co/v1/fetch", { method: "POST", headers: { "Content-Type": "application/json", "Authorization": "Bearer sofya_live_..." }, body: JSON.stringify({ urls: ["https://example.com"] }) }); console.log(await resp.json()); ``` -------------------------------- ### curl example - POST /v1/search Source: https://sofya.co/llms-full.txt curl command to call the Search API. Uses Bearer token authentication and sends a JSON body with query and search_depth. Replace the API key placeholder. ```bash curl -X POST https://sofya.co/v1/search \ -H "Content-Type: application/json" \ -H "Authorization: Bearer sofya_live_..." \ -d '{"query": "latest AI news", "search_depth": "basic"}' ``` -------------------------------- ### GET /v1/auth/usage Source: https://sofya.co/llms-full.txt Get your daily usage breakdown. Rows are per day, endpoint and API key, newest day first, so one day can have several rows for the same endpoint if you use more than one key. Each row names its key in `api_key_id` and `api_key_name`; both are null for rows not tied to a key (older usage, and searches on search.sofya.co). ```APIDOC ## GET /v1/auth/usage ### Description Get your daily usage breakdown. Rows are per day, endpoint and API key, newest day first, so one day can have several rows for the same endpoint if you use more than one key. Each row names its key in `api_key_id` and `api_key_name`; both are null for rows not tied to a key (older usage, and searches on search.sofya.co). ### Method GET ### Endpoint /v1/auth/usage ### Parameters #### Query Parameters - **days** (integer) - Optional - 1-90, default 7. Out-of-range values are clamped. - **offset_days** (integer) - Optional - Default 0. Skip this many recent days, for paging back in time. - **api_key_id** (string) - Optional - Only count requests made with this key (its id from the dashboard). An id that is not one of your keys returns 404. ### Response #### Success Response (200) - **date** (string) - The date of the usage row. - **endpoint** (string) - The endpoint path. - **request_count** (integer) - Number of requests. - **total_credits** (integer) - Total credits used. - **api_key_id** (string) - ID of the API key used, null if not tied to a key. - **api_key_name** (string) - Name of the API key used, null if not tied to a key. ### Request Example ```bash curl "https://sofya.co/v1/auth/usage?days=30" \ -H "Authorization: Bearer sofya_live_..." ``` #### Response Example ```json [ { "date": "2026-10-08", "endpoint": "/v1/search", "request_count": 3, "total_credits": 6, "api_key_id": "4505fa6c-edff-eff6-7aa9-547504df43ee", "api_key_name": "Production" } ] ``` ``` -------------------------------- ### Python example - httpx POST /v1/search Source: https://sofya.co/llms-full.txt Python code using httpx to call the Search API. Sets a 90-second timeout, longer than the server's limit, to receive either the answer or an error. Requires httpx library. ```python import httpx resp = httpx.post("https://sofya.co/v1/search", headers={"Authorization": "Bearer sofya_live_..."}, json={"query": "latest AI news", "search_depth": "basic"}, timeout=90) # longer than the server's limit, so you get its answer or error print(resp.json()) ``` -------------------------------- ### GET /v1/updates Source: https://sofya.co/llms-full.txt Returns the list of user-facing changes as JSON. No API key required. ```APIDOC ## GET /v1/updates ### Description Changelog: `GET /v1/updates` (no API key) returns the list of user-facing changes as JSON. ### Method GET ### Endpoint /v1/updates ### Response #### Success Response (200) - Returns a list of user-facing changes as JSON. ``` -------------------------------- ### GET /v1/auth/me Source: https://sofya.co/docs Retrieves account information for the authenticated user, including credit balance, plan tier, and total requests. This endpoint is free to use. ```APIDOC ## GET /v1/auth/me ### Description Get your account info: credit balance, tier and total requests. Free. ### Method GET ### Endpoint /v1/auth/me ### Response #### Success Response (200) - **credits** (number) - Total spendable balance, plan_credits (free-tier credits) plus purchased_credits. - **plan_credits** (number) - Free-tier credits. - **purchased_credits** (number) - Purchased credits. - **is_free_tier** (boolean) - Indicates if the user is on the free tier. - **credits_reset_at** (string) - When free-tier credits next reset to 2,000 (every 30 days). Purchased credits never reset. - **total_requests** (number) - Total number of requests made. - **api_key** (string|null) - Always null, unless the signed-in dashboard asks for it. - **last_login_method** (string) - The method used for the last login. - **email** (string) - The user's email address. - **email_verified** (boolean) - Whether the email is verified. - **github_username** (string) - The GitHub username. - **has_billing_portal** (boolean) - Whether the user has a billing portal. - **new_ip_alerts_enabled** (boolean) - Whether new IP alerts are enabled. - **low_balance_alerts_enabled** (boolean) - Whether low balance alerts are enabled. - **low_balance_threshold** (number|null) - The low balance threshold. - **low_balance_threshold_auto** (number) - The automatic low balance threshold. #### Response Example ```json { "credits": 1994, "plan_credits": 1994, "purchased_credits": 0, "is_free_tier": true, "credits_reset_at": "2026-11-04T12:00:00Z", "total_requests": 3, "api_key": null, "last_login_method": "github", "email": "user@example.com", "email_verified": true, "github_username": "octocat", "has_billing_portal": false, "new_ip_alerts_enabled": true, "low_balance_alerts_enabled": true, "low_balance_threshold": null, "low_balance_threshold_auto": 1000 } ``` ``` -------------------------------- ### GET /v1/billing/balance Source: https://sofya.co/docs Check the balance of the API key used for the call. Returns current credits, plan and purchase details, key usage limits, and pricing info. This call is free. ```APIDOC ## [GET] /v1/billing/balance ### Description Check the balance of the API key used for the call. Returns current credits, plan and purchase details, key usage limits, and pricing info. This call is free. ### Method GET ### Endpoint https://sofya.co/v1/billing/balance ### Response #### Success Response (200) - **credits** (number) - Current total credits. - **plan_credits** (number) - Credits from the plan. - **purchased_credits** (number) - Credits purchased. - **credits_reset_at** (string/null) - Reset timestamp for plan credits (null if not applicable). - **key_monthly_cap** (number/null) - Monthly cap for the key (null if no limit). - **key_credits_used_this_month** (number) - Credits used this month for the key. - **key_total_cap** (number/null) - Total cap for the key (null if no limit). - **key_credits_used_total** (number/null) - Total credits used (only present if there is a total limit). - **key_expires_at** (string/null) - Expiration time for the key (null if no limit). - **credits_per_usd** (number) - Credits per US dollar. - **min_topup_usd** (number) - Minimum top-up amount in USD. - **max_topup_usd** (number) - Maximum top-up amount in USD. - **top_up_url** (string) - Dashboard URL with top-up query parameter. - **pay_url** (string) - Machine Payments Protocol link for minimum purchase. #### Response Example ``` { "credits": 3994, "plan_credits": 0, "purchased_credits": 3994, "credits_reset_at": null, "key_monthly_cap": 5000, "key_credits_used_this_month": 6, "key_total_cap": null, "key_credits_used_total": null, "key_expires_at": null, "credits_per_usd": 400, "min_topup_usd": 10, "max_topup_usd": 25000, "top_up_url": "https://sofya.co/dashboard?topup=10", "pay_url": "https://sofya.co/v1/billing/pay/..." } ``` ``` -------------------------------- ### API Key Authentication Headers Source: https://sofya.co/docs Send your API key using either the Authorization header with Bearer scheme or the X-API-Key header. Keys must start with 'sofya_live_' or 'ay_live_' (older keys). ```http Authorization: Bearer sofya_live_your_key_here # or X-API-Key: sofya_live_your_key_here ``` -------------------------------- ### GET /v1/billing/balance Source: https://sofya.co/auth Retrieves the current credit balance and key-specific limits for the authenticated API key. This is a direct call to check remaining credits and usage thresholds. ```APIDOC ## GET /v1/billing/balance ### Description Retrieves the current credit balance and key-specific usage information. ### Method GET ### Endpoint https://sofya.co/v1/billing/balance ### Response #### Success Response (200) - `credits` - The current credit balance. - `key_monthly_cap` - The monthly spending cap set for this key. - `key_credits_used_this_month` - Credits used by this key in the current month. - `key_total_cap` - The total spending cap set for this key. - `key_credits_used_total` - Total credits used by this key. - `key_expires_at` - Expiry date/time of the key. ``` -------------------------------- ### GET /v1/auth/me - Account Info Response Source: https://sofya.co/docs Returns account details including credit balance, tier, total requests, and user profile. Free tier users have 2,000 credits that reset every 30 days; purchased credits never reset. `api_key` is typically null unless the dashboard requests it. ```json { "credits": 1994, "plan_credits": 1994, "purchased_credits": 0, "is_free_tier": true, "credits_reset_at": "2026-11-04T12:00:00Z", "total_requests": 3, "api_key": null, "last_login_method": "github", "email": "user@example.com", "email_verified": true, "github_username": "octocat", "has_billing_portal": false, "new_ip_alerts_enabled": true, "low_balance_alerts_enabled": true, "low_balance_threshold": null, "low_balance_threshold_auto": 1000 } ``` -------------------------------- ### GET /v1/billing/balance response 200 Source: https://sofya.co/llms-full.txt Response from checking the balance with an API key. The `key_` fields describe limits for the key used: `key_monthly_cap`, `key_total_cap`, and `key_expires_at` are null when no such limit exists; `key_credits_used_total` is filled only when a total limit is set. A `pay_url` is included for the minimum purchase. ```json { "credits": 3994, "plan_credits": 0, "purchased_credits": 3994, "credits_reset_at": null, "key_monthly_cap": 5000, "key_credits_used_this_month": 6, "key_total_cap": null, "key_credits_used_total": null, "key_expires_at": null, "credits_per_usd": 400, "min_topup_usd": 10, "max_topup_usd": 25000, "top_up_url": "https://sofya.co/dashboard?topup=10", "pay_url": "https://sofya.co/v1/billing/pay/..." } ``` -------------------------------- ### GET /v1/auth/usage Source: https://sofya.co/docs Retrieves your daily usage breakdown per day, endpoint, and API key. The response contains rows sorted by date (newest first), with each row indicating the request count, total credits, and associated API key details. ```APIDOC ## [GET] /v1/auth/usage ### Description Get your daily usage breakdown. Rows are per day, endpoint and API key, newest day first, so one day can have several rows for the same endpoint if you use more than one key. Each row names its key in `api_key_id` and `api_key_name`; both are null for rows not tied to a key (older usage, and searches on search.sofya.co). ### Method GET ### Endpoint /v1/auth/usage ### Parameters #### Query Parameters - **days** (integer) - Optional - 1-90, default 7. Out-of-range values are clamped. - **offset_days** (integer) - Optional - Default 0. Skip this many recent days, for paging back in time. - **api_key_id** (string) - Optional - Only count requests made with this key (its id from the dashboard). An id that is not one of your keys returns 404. ### Response #### Success Response (200) - **date** (string) - The date of the usage row. - **endpoint** (string) - The API endpoint used. - **request_count** (integer) - Number of requests made. - **total_credits** (number) - Total credits consumed. - **api_key_id** (string|null) - The ID of the API key used, or null if not tied to a key. - **api_key_name** (string|null) - The name of the API key used, or null if not tied to a key. ### Request Example ``` curl "https://sofya.co/v1/auth/usage?days=30" \ -H "Authorization: Bearer sofya_live_..." ``` #### Response Example ``` [ { "date": "2026-10-08", "endpoint": "/v1/search", "request_count": 3, "total_credits": 6, "api_key_id": "4505fa6c-edff-eff6-7aa9-547504df43ee", "api_key_name": "Production" } ] ``` ``` -------------------------------- ### GET /api/v2/status.json Source: https://sofya.co/llms-full.txt Page metadata and overall indicator only. Cheapest poll if you only need up/down. Example provided. ```APIDOC ## GET /api/v2/status.json ### Description Page metadata and overall indicator only. Cheapest poll if you only need up/down. No API key needed. ### Method GET ### Endpoint /api/v2/status.json ### Response #### Success Response (200) - **page** (object) - Page metadata. - **status** (object) - Overall indicator and description. - **indicator** (string) - `none` (operational), `minor` (degraded), or `major` (down). - **description** (string) - Status description. #### Response Example ```json { "page": { "id": "sofya", "name": "Sofya Status", "url": "https://status.sofya.co", "time_zone": "Etc/UTC", "updated_at": "2026-10-09T14:00:30+00:00" }, "status": { "indicator": "none", "description": "All Systems Operational" } } ``` ``` -------------------------------- ### Sofya MCP tools overview Source: https://sofya.co/docs List of Sofya MCP tools available: search, fetch, extract, research, get_balance, and buy_credits. Each tool has a credit cost and parameters; they return JSON same as REST endpoints and only read the web. ```markdown ### Tools search 1-2 credits Web search that returns page content. +2 with an AI answer. Takes `query`, `search_depth`, `max_results`, `include_answer`, `include_domains`, `exclude_domains`, `topic`, `freshness`. [Reference](#search) fetch 1 credit per URL URLs and documents as clean markdown; failed URLs are free. Takes `urls`, `include_raw_html`. [Reference](#fetch) extract 10 credits An AI answer to a question about one page. Takes `url`, `prompt`. [Reference](#extract) research 50 credits A cited report from many searches and sources. Takes `query`, `topic`, `freshness`, `max_sources`. [Reference](#research) get_balance free Credits left, and the key's limits if it has any. Same as `GET /v1/billing/balance`. [Reference](#agent-billing) buy_credits free A payment link for the user to open. Charges nothing itself. Takes `amount_usd`. Same as `POST /v1/billing/topup`. [Reference](#agent-billing) ``` -------------------------------- ### Curl: Agent sign-up request (POST /v1/agent/signup) Source: https://sofya.co/llms-full.txt Requests a claim token and verification URI for an agent without a key. Optional fields: 'client_name' (shown on approval page) and 'login_hint' (email). Also supports 'amount_usd' ($10–$25,000) to request credits. ```bash curl -X POST https://sofya.co/v1/agent/signup \ -H "Content-Type: application/json" \ -d '{"client_name": "My agent", "login_hint": "you@example.com"}' ``` -------------------------------- ### Research Examples in curl, Python, and JavaScript Source: https://sofya.co/docs Examples of calling the research endpoint via curl, Python with httpx, and JavaScript fetch. The Python version sets a 120-second timeout, noting research usually takes 15-25 seconds. The JavaScript example requires Node 18+ and top-level await. ```bash curl -X POST https://sofya.co/v1/research \ -H "Content-Type: application/json" \ -H "Authorization: Bearer sofya_live_..." \ -d '{"query": "How do modern LLMs handle long context?"}' ``` ```python import httpx resp = httpx.post("https://sofya.co/v1/research", headers={"Authorization": "Bearer sofya_live_..."}, json={"query": "How do modern LLMs handle long context?"}, timeout=120) # research usually takes 15-25 s print(resp.json()) ``` ```javascript // Node 18+: save as example.mjs (top-level await needs a module) const resp = await fetch("https://sofya.co/v1/research", { method: "POST", headers: { "Content-Type": "application/json", "Authorization": "Bearer sofya_live_..." }, body: JSON.stringify({ query: "How do modern LLMs handle long context?" }) }); console.log(await resp.json()); ``` -------------------------------- ### GET /v1/auth/transactions Source: https://sofya.co/llms-full.txt Get your last 50 top-ups and account adjustments, newest first. Per-request charges and refunds are not listed here; use usage for those. ```APIDOC ## GET /v1/auth/transactions ### Description Get your last 50 top-ups and account adjustments, newest first. Per-request charges and refunds are not listed here; use usage for those. ### Method GET ### Endpoint /v1/auth/transactions ### Response #### Success Response (200) Returns a list of transaction objects, each containing: - **id** (string) - Unique identifier for the transaction. - **type** (string) - Either `credit` or `debit`. - **amount** (integer) - Amount of credits in the transaction. - **endpoint** (string) - The endpoint associated with the transaction. - **balance_after** (integer) - Balance after the transaction. - **created_at** (string) - Timestamp of when the transaction occurred. - **has_receipt** (boolean) - True for paid top-ups. - **amount_usd_cents** (integer or null) - What was actually charged (negative for refunds and disputes) and null for adjustments; don't work out dollars from credits, since older top-ups were sold at a different rate. #### Response Example ```json [ { "id": "uuid", "type": "credit", "amount": 4000, "endpoint": "top-up", "balance_after": 5994, "created_at": "2026-10-08T12:00:00Z", "has_receipt": true, "amount_usd_cents": 1000 } ] ``` ``` -------------------------------- ### POST /v1/billing/topup Source: https://sofya.co/auth Initiates a credit purchase by providing a payment URL for the user. It returns both a checkout URL for a Stripe payment page and a pay_url for MPP-compatible wallets. ```APIDOC ## POST /v1/billing/topup ### Description Creates a top-up request and returns payment URLs to add credits to an account. ### Method POST ### Endpoint https://sofya.co/v1/billing/topup ### Request Body - `amount_usd` (integer) - Required - Purchase amount in whole US dollars (10 to 25,000). 1 USD = 400 credits. ### Request Example ```json {"amount_usd": 10} ``` ### Response #### Success Response (200) - `checkout_url` - URL for a Stripe payment page (for persons, no API key needed). - `pay_url` - Payment URL for MPP-compatible wallets (valid 24 hours; answers 402 with WWW-Authenticate: Payment challenge, and 404 after 24 hours). ``` -------------------------------- ### curl POST topup request to /v1/billing/topup Source: https://sofya.co/llms-full.txt Create a payment link for a top-up of $10. The call is free and nothing is charged until the user pays on the Stripe page. `amount_usd` must be a whole dollar amount between $10 and $25,000; below the minimum returns a 400 and above the maximum a 422. At most 20 links per account per hour (429 after that). ```bash curl -X POST https://sofya.co/v1/billing/topup \ -H "Authorization: Bearer sofya_live_your_key_here" \ -H "Content-Type: application/json" \ -d '{"amount_usd": 10}' ``` -------------------------------- ### get_balance Source: https://sofya.co/docs Returns the credits left and the key's limits if any. Same as GET /v1/billing/balance. ```APIDOC ## [MCP Tool] get_balance ### Description Credits left, and the key's limits if it has any. Same as `GET /v1/billing/balance`. ### Parameters None ### Response The response contains the credits left and any key limits. Errors are returned as a tool result with `isError: true`. ``` -------------------------------- ### POST /v1/fetch Source: https://sofya.co/llms-full.txt Fetch up to 10 URLs in parallel and return their content as clean markdown. Costs 1 credit per URL that succeeds; failed URLs are not charged. ```APIDOC ## POST /v1/fetch ### Description Fetch up to 10 URLs in parallel and return their content as clean markdown. Works on web pages and documents: PDF, Word (DOCX, DOC), Excel (XLSX, XLS), PowerPoint (PPTX, PPT), OpenDocument, EPUB, RTF, CSV, XML and plain text. Costs 1 credit per URL that succeeds; a URL that fails comes back with `success: false` and is not charged. ### Method POST ### Endpoint /v1/fetch ### Parameters #### Request Body - `urls` (string[]) - Required - 1-10 URLs. An empty list is a 400; more than 10 is a 422. A URL listed twice is fetched, returned and charged once. - `include_raw_html` (boolean) - Optional - Default false. Also return the page's raw HTML. ### Response #### Success Response (200) - `results` (array) - List of result objects. - `title` (string) - The page title. - `url` (string) - The URL that was fetched. - `content` (string) - The content as markdown. - `raw_html` (nullable string) - Raw HTML if requested and available, else null. - `published_time` (nullable string) - Publication date in YYYY-MM-DD from page metadata when available, else null. - `success` (boolean) - Whether the fetch succeeded. - `error` (nullable string) - Error message if failed. - `low_content` (boolean) - True if page returned under 300 characters of readable text. - `notice` (nullable string) - Explanation when low_content is true. - `credits_used` (integer) - Number of credits used. - `credits_remaining` (integer) - Credits remaining. ### Response Fields - `success / error`: Each URL succeeds or fails on its own. A URL that hasn't finished after 50 seconds gives up and returns `success: false` with an `error` message; the other URLs are unaffected. - `low_content / notice`: `low_content` is true when a page came back with under 300 characters of readable text: it may need JavaScript, sit behind a login or cookie wall, or be image-only. `notice` then says so in words. Still `success: true` and still charged. - **Size limits**: 5 MB for HTML pages, 50 MB for documents. - `raw_html`: Null unless `include_raw_html` is true, and may still be null for non-HTML content (such as documents) and for some sites. - `published_time`: `YYYY-MM-DD` from page metadata when available, else null. ### Request Example ```json { "urls": ["https://example.com"], "include_raw_html": false } ``` ### Response Example ```json { "results": [ { "title": "Example Page", "url": "https://example.com", "content": "# Markdown content...", "raw_html": null, "published_time": null, "success": true, "error": null, "low_content": false, "notice": null } ], "credits_used": 1, "credits_remaining": 1999 } ``` ```