# See what a run cost

Every reply an agent writes is a [run](/docs/concepts/runs.md): see the tokens it used and the credits it cost.

## Before you start

You need a reply from an agent. See [Chat with an agent](/docs/agents/chat.md).

## See what a run cost

**Studio**

1. In your project, open **Chat**. It opens your last conversation.
2. Click **Show sidebar**.
3. Click the conversation with your agent.
4. Hover the agent's reply.
5. Click the token count under it. **Run usage** shows **Model calls**, the tokens and **Model credits**.
6. Click **View run**.
7. Scroll to **Analytics**. You should now see the run's **Model credits**, **Provider cost** and **Total cost**.

**Code**

1. [Sign in](/docs/start/authentication.md) to the CLI.
2. Set `PROJECT` to your project's ID ([Find your IDs](/docs/authentication/api-keys.md#find-your-ids)): `export PROJECT=<id>`.
3. List the project's runs, newest first:

```bash
npx veryfront project runs project-list --project-reference $PROJECT
```

4. Set `RUN_ID` to the `id` of the run you want, from the list above: `export RUN_ID=<id>`.
5. Get the run. You should now see `usage` with its `model_calls`, `tokens`, and `cost` with its `credits`:

```bash
npx veryfront project runs get --run-id $RUN_ID
```

### Try it in a sandbox

```playground
step: Set PROJECT | export PROJECT=$VERYFRONT_PROJECT_ID
step: Add the support agent | curl -fsS -X POST https://api.veryfront.com/projects/$PROJECT/agents -H "Authorization: Bearer $VERYFRONT_API_KEY" -H "Content-Type: application/json" -d '{ "id": "support", "name": "Support assistant", "system_prompt": "Answer customer questions about orders and refunds. Refunds take 5 business days. Keep replies to two sentences." }'
step: Ask it a question | export CONVERSATION=$(curl -fsS -X POST https://api.veryfront.com/conversations -H "Authorization: Bearer $VERYFRONT_API_KEY" -H "Content-Type: application/json" -d '{ "project_reference": "'$PROJECT'", "type": "chat", "title": "Refund question", "initial_message": { "role": "user", "parts": [{ "type": "text", "text": "How long does a refund take?" }] } }') && export CONVERSATION_ID=$(printf '%s' "$CONVERSATION" | jq -r .id) MESSAGE_ID=$(printf '%s' "$CONVERSATION" | jq -r .initial_message_id)
step: Let the agent answer | curl -fsS -X POST https://api.veryfront.com/runs -H "Authorization: Bearer $VERYFRONT_API_KEY" -H "Content-Type: application/json" -d '{ "project_id": "'$PROJECT'", "conversation_id": "'$CONVERSATION_ID'", "target": { "type": "agent", "id": "support" }, "input": { "agent_id": "support", "messages": [{ "id": "'$MESSAGE_ID'", "role": "user", "parts": [{ "type": "text", "text": "How long does a refund take?" }] }], "tools": [], "context": [] }, "config": { "agent_admission": { "mode": "project", "input_message_id": "'$MESSAGE_ID'" } }, "execution": { "runtime": { "type": "main_branch" } } }'
step: Wait for the answer | for i in $(seq 60); do curl -s https://api.veryfront.com/projects/$PROJECT/runs -H "Authorization: Bearer $VERYFRONT_API_KEY" | grep -q '"status":"completed"' && break; sleep 3; done
step: List the runs | npx veryfront project runs project-list --project-reference $PROJECT
step: Set RUN_ID | export RUN_ID=$(npx veryfront project runs project-list --project-reference $PROJECT | jq -r '.data[0].id')
check: npx veryfront project runs get --run-id $RUN_ID
expect: "credits"
```

**API**

1. Set `PROJECT` to your project's ID ([Find your IDs](/docs/authentication/api-keys.md#find-your-ids)): `export PROJECT=<id>`.
2. List the project's runs, newest first, with your [API key](/docs/authentication/api-keys.md):

```bash
curl https://api.veryfront.com/projects/$PROJECT/runs \
  -H "Authorization: Bearer $VERYFRONT_API_KEY"
```

3. Set `RUN_ID` to the `id` of the run you want, from the list above: `export RUN_ID=<id>`.
4. Get the run. You should now see `usage` with its `model_calls`, `tokens`, and `cost` with its `credits`:

```bash
curl https://api.veryfront.com/runs/$RUN_ID \
  -H "Authorization: Bearer $VERYFRONT_API_KEY"
```

### Try it in a sandbox

```playground
step: Set PROJECT | export PROJECT=$VERYFRONT_PROJECT_ID
step: Add the support agent | curl -fsS -X POST https://api.veryfront.com/projects/$PROJECT/agents -H "Authorization: Bearer $VERYFRONT_API_KEY" -H "Content-Type: application/json" -d '{ "id": "support", "name": "Support assistant", "system_prompt": "Answer customer questions about orders and refunds. Refunds take 5 business days. Keep replies to two sentences." }'
step: Ask it a question | export CONVERSATION=$(curl -fsS -X POST https://api.veryfront.com/conversations -H "Authorization: Bearer $VERYFRONT_API_KEY" -H "Content-Type: application/json" -d '{ "project_reference": "'$PROJECT'", "type": "chat", "title": "Refund question", "initial_message": { "role": "user", "parts": [{ "type": "text", "text": "How long does a refund take?" }] } }') && export CONVERSATION_ID=$(printf '%s' "$CONVERSATION" | jq -r .id) MESSAGE_ID=$(printf '%s' "$CONVERSATION" | jq -r .initial_message_id)
step: Let the agent answer | curl -fsS -X POST https://api.veryfront.com/runs -H "Authorization: Bearer $VERYFRONT_API_KEY" -H "Content-Type: application/json" -d '{ "project_id": "'$PROJECT'", "conversation_id": "'$CONVERSATION_ID'", "target": { "type": "agent", "id": "support" }, "input": { "agent_id": "support", "messages": [{ "id": "'$MESSAGE_ID'", "role": "user", "parts": [{ "type": "text", "text": "How long does a refund take?" }] }], "tools": [], "context": [] }, "config": { "agent_admission": { "mode": "project", "input_message_id": "'$MESSAGE_ID'" } }, "execution": { "runtime": { "type": "main_branch" } } }'
step: Wait for the answer | for i in $(seq 60); do curl -s https://api.veryfront.com/projects/$PROJECT/runs -H "Authorization: Bearer $VERYFRONT_API_KEY" | grep -q '"status":"completed"' && break; sleep 3; done
step: List the runs | curl https://api.veryfront.com/projects/$PROJECT/runs -H "Authorization: Bearer $VERYFRONT_API_KEY"
step: Set RUN_ID | export RUN_ID=$(curl -s https://api.veryfront.com/projects/$PROJECT/runs -H "Authorization: Bearer $VERYFRONT_API_KEY" | jq -r '.data[0].id')
check: curl https://api.veryfront.com/runs/$RUN_ID -H "Authorization: Bearer $VERYFRONT_API_KEY"
expect: "credits"
```

## With MCP

1. Call `veryfront__list_project_runs` with `"project_reference": "my-project"`, your project's slug or ID. The newest run is first.
2. Call `veryfront__get_run` with `"run_id"` set to the `id` of the run you want, from the list. It worked when you see its `usage` with `model_calls` and `tokens`, and `usage.cost` with its `credits`.

## Next steps

* [Debug a run](/docs/observability/debug.md)
* [See what a project costs](/docs/observability/project-analytics.md)
