Authorization

    Desearch API requests are authenticated with an API key from Desearch Console. Send the key in the HTTP Authorization header on every request.

    http
    Authorization: $DESEARCH_API_KEY

    Do not prefix the key with Bearer unless your Desearch account or SDK explicitly instructs you to. Use the exact key value shown when the key is generated.

    cURL example

    bash
    curl --request POST 'https://api.desearch.ai/desearch/ai/search' \ --header 'Authorization: $DESEARCH_API_KEY' \ --header 'Content-Type: application/json' \ --data '{ "prompt": "latest TAO trends", "tools": ["web", "twitter"], "date_filter": "PAST_24_HOURS", "count": 10, "streaming": false }'

    Python example

    python
    import os import requests url = "https://api.desearch.ai/desearch/ai/search" headers = { "Authorization": os.environ["DESEARCH_API_KEY"], "Content-Type": "application/json", } payload = { "prompt": "latest TAO trends", "tools": ["web", "twitter"], "date_filter": "PAST_24_HOURS", "count": 10, "streaming": False, } response = requests.post(url, json=payload, headers=headers, timeout=60) response.raise_for_status() print(response.json()) print("request cost usd:", response.headers.get("X-Desearch-Cost-Usd"))

    JavaScript example

    js
    const response = await fetch("https://api.desearch.ai/desearch/ai/search", { method: "POST", headers: { Authorization: process.env.DESEARCH_API_KEY, "Content-Type": "application/json", }, body: JSON.stringify({ prompt: "latest TAO trends", tools: ["web", "twitter"], date_filter: "PAST_24_HOURS", count: 10, streaming: false, }), }); if (!response.ok) { throw new Error(`Desearch API error ${response.status}: ${await response.text()}`); } console.log(await response.json()); console.log("request cost usd:", response.headers.get("X-Desearch-Cost-Usd"));

    Security checklist

    • Store keys in environment variables or a secret manager.
    • Never commit keys to Git.
    • Never expose keys in browser/client-side code.
    • Rotate or revoke a key immediately if it is leaked.
    • Use separate keys for development, staging, and production when possible.

    Troubleshooting

    StatusLikely causeFix
    401Missing, invalid, revoked, or wrong key.Regenerate the key in Console and update the server-side environment variable.
    422Auth is valid, but request params/body are invalid.Compare your request to the API Reference and remove stale fields.
    429The key exceeded a limit.Add retry/backoff, reduce concurrency, or upgrade/contact support.