# Quick start

Send a message to an agent and read its answer with a handful of API calls. You need a platform API key, which you create in
the [dashboard](https://useclick.ai/dashboard), and an API key from a model provider. The API base URL is
`https://api.useclick.ai/v1`.

```sh
export CLICK_API_URL="https://api.useclick.ai/v1"
export CLICK_API_KEY="your-platform-api-key"
```

**1. Store your model API key.** Save the returned `id` as the credential ID.

```sh
curl "$CLICK_API_URL/credentials" -H "Authorization: Bearer $CLICK_API_KEY" -H "Content-Type: application/json" \
  -d '{"name": "Anthropic", "category": "model", "provider": "anthropic", "api_key": "your-anthropic-api-key"}'
```

**2. Choose a model.** `GET /models` lists the catalog of providers and model IDs; choose a model from your
credential's provider.

```sh
curl "$CLICK_API_URL/models" -H "Authorization: Bearer $CLICK_API_KEY"
```

**3. Create an agent.** Save `latest_version.id` from the response.

```sh
curl "$CLICK_API_URL/agents" -H "Authorization: Bearer $CLICK_API_KEY" -H "Content-Type: application/json" -d '{
  "name": "Assistant",
  "config": {
    "model": {"provider": "anthropic", "id": "claude-sonnet-5-5", "credential_id": "<credential_id>"},
    "instructions": "Answer clearly and concisely.",
    "tools": [{"type": "platform", "name": "web_search"}]
  }
}'
```

**4. Start a session.** Save the returned `id` as the session ID.

```sh
curl "$CLICK_API_URL/sessions" -H "Authorization: Bearer $CLICK_API_KEY" -H "Content-Type: application/json" \
  -d '{"agent_version_id": "<latest_version.id>"}'
```

**5. Submit input.** The `202` response is the saved submission. A `request_id` makes retries of this request safe.

```sh
curl "$CLICK_API_URL/sessions/<session_id>/submissions" -H "Authorization: Bearer $CLICK_API_KEY" \
  -H "Content-Type: application/json" -d '{"content": "What is new in TypeScript this year?", "request_id": "req-1"}'
```

**6. Read the outcome and the answer.** Read the submission until its `status` is `done`, `cancelled` or `failed`,
then fetch the answer entry it names.

```sh
curl "$CLICK_API_URL/sessions/<session_id>/submissions/<submission_id>" -H "Authorization: Bearer $CLICK_API_KEY"
curl "$CLICK_API_URL/sessions/<session_id>/entries?min_entry_id=<answer>&max_entry_id=<answer>" \
  -H "Authorization: Bearer $CLICK_API_KEY"
```

Your output looks similar to this:

```json
{"id": 1, "conversation_id": 1, "request_id": "req-1", "type": "input", "status": "done", "entry": 2, "answer": 5}
{"data": [{"id": 5, "conversation_id": 1, "kind": "message", "model": [{"role": "assistant",
  "content": [{"type": "text", "text": "Here are this year's TypeScript highlights..."}], "stop_reason": "stop"}]}],
 "next_cursor": null}
```

What happened:

1. Click saved your input and placed it in the session's conversation.
2. The model wrote a `codemode` program that called `web_search`, and Click ran it and recorded each tool call.
3. The model answered, and Click committed the answer as an entry and marked the submission `done`.
4. The session kept its history, so the next submission continues the same conversation.

The [runnable Python example](/reference/examples/saas.py) performs these steps with only the standard library:

```sh
export MODEL_PROVIDER="anthropic"
export MODEL_ID="claude-sonnet-5-5"
export MODEL_API_KEY="your-model-api-key"
python3 saas.py "Say hello in one sentence."
python3 saas.py --session <session_id> "A follow-up question"
```

Keep platform and provider API keys on your backend. From here, add your own tools, stream progress to your UI and
register a webhook, as described in the guides below.
