# Invoke an agent

Send prompts to a deployed agent from the Chat Playground, the terminal, Python, or any HTTP client.

## Prerequisites

- An agent with status **Deployed**. See [Deploy an agent](deploy-an-agent.md).
- For the CLI, Python or HTTP: the `arena` CLI signed in, or a CLI API key in `ARENA_API_KEY`. See [Install and sign in](../cli/install.md).

## Send a prompt

### Web app

1. Open **Agents** in the sidebar and click the agent’s card.
2. The agent page opens on **Chat Playground**. Type a message and send it. The reply streams in as it is generated.

The playground keeps each conversation as a session. Start a new one, search, rename or reopen earlier ones from the session list beside the chat. If the agent’s memory scope is **Organization**, you also see sessions other members started.

The other tabs hold code to copy, already filled in with this agent’s name and endpoint:

| Tab              | What it shows                                                             |
|------------------|---------------------------------------------------------------------------|
| **Arena client** | Python, using `ArenaClient` from `agilerl`                                |
| **Arena CLI**    | The `arena agent generate` command                                        |
| **Manual HTTP**  | Python `requests` call to the endpoint, with your key as a `Bearer` token |

The **Endpoint** row in the left panel has a copy button for the endpoint URL.

### CLI

```bash
arena agent generate gsm8k-cispo --prompt "Natalia sold 48 clips in April and half as many in May. How many in total?"
```

The completion streams to your terminal. Later prompts continue the same conversation, so the agent remembers what you asked. Add `--new-session` to start over.

To skip the name on every call, select the agent once with `arena agent run gsm8k-cispo`, then run `arena agent generate --prompt "..."`.

`arena agent sessions list` lists your conversations with the agent, and `arena agent sessions resume` picks one up again. Flags are in the [command reference](../cli/command-reference.md).

### Python

```python
from agilerl import ArenaClient

with ArenaClient() as client:
    with client.open_inference_agent("gsm8k-cispo") as agent:
        result = agent.generate("Your prompt here")
        if result.results:
            print(result.results[0].completion)
```

`ArenaClient()` uses your `arena login` session, or `ARENA_API_KEY` when it is set. More methods are on the [Python client](../cli/python-client.md) page.

## Call the endpoint from your own code

Anything that can send HTTPS requests can call the agent. Copy the **Manual HTTP** snippet from the agent page: it has the full URL and request body. Authenticate with your CLI API key as a `Bearer` token. The key belongs to you, not to the agent, so the same key works for every agent you can see.

Request and response fields, streaming, and chat sessions over HTTP are in the [Inference contract](../reference/inference-contract.md).

## If calls fail

Calls only succeed while the agent shows **Deployed**. If it shows **Deploying**, wait. If it shows **Stopped**, **Not deployed** or **Deployment failed**, start it again with **Deploy** on its page. Statuses are explained in [Deploy an agent](deploy-an-agent.md#statuses).
