# Quickstart

> Make your first Openpipe Health API request.

Source: https://openpipe.health/docs/quickstart/

> **Using a coding agent?:** Skip the typing: [copy one prompt](https://openpipe.health/docs/agents.md#copy-this-to-your-agent) into Claude Code, Cursor or any other agent. It makes these same requests for you once `OPH_API` and `OPH_KEY` are set.

## 1. Set the base URL

Every path in these docs is relative to the base URL of your deployment. When you run the repo locally with `bun run dev`, that is `http://localhost:4318`.

```sh
export OPH_API=http://localhost:4318
```

Check that the API is up. This endpoint needs no key:

```sh
curl $OPH_API/api/health
```

## 2. Create an API key

Sign in to the app at `/app`, find **API key**, and select **Create a key**. Keys start with `oph_` and are shown once, so copy it straight away.

The key belongs to the [workspace](https://openpipe.health/docs/workspaces.md) you created it in and spends that workspace's credits. In an organization workspace, only owners and admins can create keys.

```sh
export OPH_KEY=oph_your_key_here
```

## 3. Search

Rank Texas clinicians by the number of total knee replacements (HCPCS `27447`) they billed to Medicare:

```sh
curl "$OPH_API/api/providers?hcpcs=27447&state=TX&limit=5" \
  -H "Authorization: Bearer $OPH_KEY"
```

The response has the rows, the SQL that produced them, the datasets it read, and what the call cost:

```json
{
  "rows": [
    {
      "npi": "1234567893",
      "name": "Jane Example",
      "credentials": "MD",
      "specialty": "Orthopedic Surgery",
      "city": "Houston",
      "state": "TX",
      "hcpcs_code": "27447",
      "services": 412,
      "patients": "398",
      "medicare_payment": "498213"
    }
  ],
  "sql": "SELECT s.npi, ... FROM medicare_service s JOIN medicare_provider m ...",
  "params": ["27447", "TX"],
  "sources": ["medicare_service", "medicare_provider"],
  "ms": 4,
  "usage": { "credits": 1, "creditsUsed": 1, "creditsLimit": 100, "txid": "81234" }
}
```

Values in example responses throughout these docs are illustrative. Field names and shapes are exact. Identifiers such as `npi`, and sums and money amounts, arrive as JSON strings.

## 4. Ask in plain English

```sh
curl "$OPH_API/api/ask" \
  -H "Authorization: Bearer $OPH_KEY" \
  -H "Content-Type: application/json" -H "Accept: application/json" \
  -d '{"question": "Which states do the most cataract surgeries per Medicare patient?"}'
```

With `Accept: application/json` the finished dashboard comes back as one JSON document after 5 to 30 seconds: a title, a summary, and two to four tiles with their columns and rows. Leave the header out and the same answer arrives as server-sent events, one tile at a time. It costs 25 credits either way. See [Ask](https://openpipe.health/docs/api/ask.md).

## 5. Connect an AI client

The same key works with the [MCP server](https://openpipe.health/docs/mcp.md), which gives Claude Code, Cursor and other MCP clients the search and lookup tools and `ask` directly:

```sh
claude mcp add --transport http openpipe "$OPH_API/mcp" \
  --header "Authorization: Bearer $OPH_KEY"
```

[Build with an AI agent](https://openpipe.health/docs/agents.md) has a ready-made prompt, rules files for Claude Code and Cursor, and the docs as [`/docs/llms.txt`](https://openpipe.health/docs/llms.txt).

## Limits to know about

Requests are [rate limited](https://openpipe.health/docs/api/errors.md#rate-limits) per workspace: 300 a minute overall, 10 for Ask and 10 for exports. A `429` response has a `Retry-After` header that says how many seconds to wait.
