# Your API

> Call a deployment’s endpoint: the URL, the key, the request, and the response.

Source: https://docs.sparset.ai/reference/your-api

Each deployment has its own call. The exact request, ready to run, is on that deployment’s **API** tab: set your key in a terminal, paste the example, and compare what comes back with the example response.

In the workspace: Deployments / your deployment / API

## What the API tab shows

Open **Deployments**, open your deployment, then open the **API** tab. Everyone on your team can see it.

- **Endpoint** (“How do I call it?”): the endpoint address, then **Send** with the method and the full call URL, a one-line summary of the call, **Copy example request** and **Copy setup for an AI agent**.
- **Details** (“What is it running?”): what the deployment serves, row by row (below).
- **First call** (“What do I run, and what comes back?”): your key, the example request, the example response, and an **If a call fails** row.
- **Setup for an AI agent**: the same call as one Markdown block for an AI agent.

The values on this tab come from your deployment, so copy from there. A sample on another deployment, or on this page, may use a different call style.

If the deployment is still being set up, the tab says “Sparset is setting up” and the endpoint and an example call appear once it is ready. If nobody has recorded the call yet, the Endpoint card says **No example request yet.** and, where it can, offers **Contact Sparset**.

## The Details rows

| Name | What it is |
| --- | --- |
| Model ID | The model this deployment serves, with a copy button. |
| Kind | Text, Image, Audio or Video. |
| Format | OpenAI chat completions, or Custom (see the example request). |
| Region | Where it runs. |
| Limits | The context size, written as tokens of context. |

A value that was never recorded reads **Not recorded yet**. That does not mean there is no limit.

## The two call styles

**OpenAI chat completions.** The call is a `POST` with a JSON body in the chat completions format: the model and a list of messages. A working call returns the answer in `choices[0].message.content`, and step 3 says there is no follow-up call. Use the path shown after **Send**: it is set per deployment, so do not assume one.

**Custom (see the example request).** The call is whatever the example shows. The body can be JSON, form fields for a file upload (`-F` in curl), or nothing for a `GET`. Some custom calls start a job. Then step 3 says “Poll the job, then fetch the result.” or “Then make the next call.” and names the follow-up call underneath.

## Make your first call

1. **Have your API key.** Step 1 shows the key’s first characters only. If there is no key, an Owner or Admin creates one there. See [API keys](https://docs.sparset.ai/reference/api-keys).
2. **Run the example.** Set the key first with `export SPARSET_API_KEY=your-key`, then paste **Copy example request** into the same terminal. OpenAI-style calls also offer **Copy request body**.
3. **Read the response.** “A working call returns this.” The example response shows the shape to expect.

## What the example looks like

Every example the app builds has the same parts: the method and call URL, the key in the `Authorization` header, and the body. For an OpenAI-style deployment it looks like this, with your values in place of the placeholders:

Call your model in three steps:

1. **Have your API key.** Calls send it in the Authorization header. An Owner or Admin creates one on the deployment’s API tab; the full key is shown once.
2. **Run the example.** Set your key, then paste the example into the same terminal:

```bash
export SPARSET_API_KEY=your-key

curl -X POST 'YOUR-CALL-URL' \
  -H "Authorization: Bearer $SPARSET_API_KEY" \
  -H 'Content-Type: application/json' \
  --data '{"model":"YOUR-MODEL-ID","messages":[{"role":"user","content":"Hello"}]}'
```

3. **Read the response.** A working call returns this:

```json
{
  "model": "YOUR-MODEL-ID",
  "choices": [{ "message": { "role": "assistant", "content": "Hi! How can I help?" } }]
}
```

This is the OpenAI chat completions format. YOUR-CALL-URL and YOUR-MODEL-ID are on the deployment’s API tab. A deployment with a custom format shows its own call there.

- `YOUR-CALL-URL` is the address after **Send** on the Endpoint card: your endpoint’s host followed by the path for this call.
- `YOUR-MODEL-ID` is the **Model ID** row under Details.
- The header is in double quotes so your shell fills in the key. In single quotes the server would receive the literal text `$SPARSET_API_KEY`.

A custom call keeps the same first two lines and changes the body. Copy it from your tab rather than adapting this one.

## Hand the call to an AI agent

**Copy setup for an AI agent** copies one Markdown block for Claude, ChatGPT, Cursor or any other agent you use. It holds the deployment’s name, the endpoint, the call, the model ID, the format, region and limits, how to send the key, the example request and response, and any follow-up calls. It tells the agent to read the key from `SPARSET_API_KEY` and never to print or log it.

Your key is never in it. Use **Show** on the Setup for an AI agent card to read the exact text before you paste it.

## If the deployment is not answering

When the deployment is down, the Endpoint card says “Not answering right now, so calls will fail.” and a status card sits at the top of the tab. See [When a call fails](https://docs.sparset.ai/reference/when-a-call-fails).
