# Setting up Gyaansetu: a guide for coding agents

Gyaansetu is a web search API for AI agents. An `advanced` Search reads the pages it finds and returns the passages that answer the query; Extract turns URLs into clean markdown.

## 1. Get an API Key

Ask the person you work for. API Keys start with `gs-`. Someone without one signs in with Google at https://web-search.gyaansetu.com and creates one under API Keys on the dashboard (https://web-search.gyaansetu.com/dashboard/keys). Every Account gets a free monthly Quota of 1,000 Credits.

Keep the key in the `GYAANSETU_API_KEY` environment variable or in the agent's user-level configuration. Never write it into a file inside a project, a commit or a log.

## 2. Connect over MCP

The remote MCP server is `https://web-search.gyaansetu.com/mcp` (Streamable HTTP). Send `Authorization: Bearer <API Key>`; a client that can't send headers can append `?apiKey=<API Key>` to the URL. Its tools are `gyaansetu_search` and `gyaansetu_extract`, and the Account Tools described below.

Claude Code, at user scope so that no project file holds the key:

```bash
claude mcp add --scope user --transport http gyaansetu https://web-search.gyaansetu.com/mcp \
  --header "Authorization: Bearer $GYAANSETU_API_KEY"
```

Codex, which reads the key from `GYAANSETU_API_KEY` when it starts:

```bash
codex mcp add gyaansetu --url https://web-search.gyaansetu.com/mcp --bearer-token-env-var GYAANSETU_API_KEY
```

Cursor, in the user-level `~/.cursor/mcp.json`, with `GYAANSETU_API_KEY` exported where Cursor starts:

```json
{
  "mcpServers": {
    "gyaansetu": {
      "url": "https://web-search.gyaansetu.com/mcp",
      "headers": {
        "Authorization": "Bearer ${env:GYAANSETU_API_KEY}"
      }
    }
  }
}
```

### Account Tools

Over MCP you can also read the Account's own figures, so you can answer your person's questions about Gyaansetu yourself. These tools are read-only and for the Account whose API Key you sent. They cost no Credits, but each call counts toward the rate limit. None returns an API Key's secret, and none creates, renames or revokes a key.

- `gyaansetu_usage`: Credits and requests per UTC day and Channel. Takes `start_date` and `end_date` (`YYYY-MM-DD`, inclusive; the last 30 days by default, at most 366 days).
- `gyaansetu_credits`: the monthly Quota, Free Credits, Credit Balance and Available Credits.
- `gyaansetu_refusals`: requests turned away, counted per day and reason (`quota_exhausted` is the `432`). Takes `days` (1 to 90, default 30).
- `gyaansetu_purchases`: Credit Pack purchases, newest first. Takes `limit` (1 to 100, default 20); `more` says whether older ones were left out.
- `gyaansetu_api_keys`: API Keys by name, prefix, created and last used.
- `gyaansetu_buy_credits`: the link where your person buys a Credit Pack, and the packs on offer. Give them the link when Credits run out.

## 3. Call it over HTTP

```bash
curl -s https://web-search.gyaansetu.com/search \
  -H "Authorization: Bearer $GYAANSETU_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{"query": "What is the Model Context Protocol?", "search_depth": "advanced", "max_results": 5}'
```

- `POST /search` takes `query`, `search_depth` (`basic` or `advanced`), `max_results` (0 to 20, default 10), `include_domains`, `exclude_domains`, `time_range` and `topic`. It returns `results[]`, each with `title`, `url`, `content` and `score` (0 to 1, highest first).
- `POST /extract` takes `urls` (1 to 20) and `format` (`markdown` or `text`), and returns `results[]` with `raw_content`, plus `failed_results[]`.
- Use what the project already has to make HTTP requests; no SDK is needed.

## Recommended defaults

- Use `advanced` when the answer must come from the pages themselves, and `basic` for quick lookups in a loop.
- Ask for 5 Results unless you need more.
- Search first, then Extract only the URLs you need in full.

## Costs

A `basic` Search costs 1 Credit, an `advanced` Search 2, and an Extract 1 Credit per 5 URLs extracted. A request that fails costs nothing.

## Errors

Every error body is `{"detail": {"error": "<message>"}}`.

- `401`: the API Key is missing, wrong or revoked.
- `429`: the rate limit; wait for `Retry-After` seconds.
- `432`: the Quota and Credit Balance are used up; more Credits are bought on the dashboard.
- `500`: a failure on Gyaansetu's side; try again.

## More

- [API reference](https://web-search.gyaansetu.com/docs.md)
- [OpenAPI description](https://web-search.gyaansetu.com/openapi.json)
- [Index of these files](https://web-search.gyaansetu.com/llms.txt)
