# Quickstart (/en/docs/developers/model/quickstart)



Call `deepseek-flash` with a cloud API key, read the amount charged, and find the record for that call. This example incurs a small charge.

## 1. Prepare your key and terminal [#1-prepare-your-key-and-terminal]

Open [Console → API Keys](https://console.deepraxis.ai/keys), click “创建 Key” (Create Key), enter a name, and create the key. Securely inject it into the current terminal as `PRAXIS_API_KEY`. Never put it in code or logs. You can use an existing key.

Install Python 3.10+ and [uv](https://docs.astral.sh/uv/getting-started/installation/). Run in a macOS / Linux terminal:

```bash
test -n "${PRAXIS_API_KEY:-}"
```

Expected: exit code 0. Exit code 1 means the variable is missing; set it before continuing. Examples default to `https://api.deepraxis.com`. To switch environments, set `PRAXIS_API_BASE` to the API origin without a trailing slash or API path.

## 2. Send a request and read its cost [#2-send-a-request-and-read-its-cost]

Save as `quickstart.py`. From that directory, run `uv run -q --no-project --with openai --with anthropic --with google-genai python quickstart.py`.

```python
import json
import os
from pathlib import Path
from openai import OpenAI

client = OpenAI(
    api_key=os.environ["PRAXIS_API_KEY"],
    base_url=os.environ.get("PRAXIS_API_BASE", "https://api.deepraxis.com") + "/openai/v1",
    timeout=90.0,
    max_retries=0,
)
raw = client.chat.completions.with_raw_response.create(
    model="deepseek-flash",
    messages=[{"role": "user", "content": "Reply with exactly: Hello Praxis."}],
    max_tokens=256,
)
reply = raw.parse()
usage = reply.usage.model_dump()
request_id = raw.headers.get("x-request-id")
generation_id = raw.headers.get("x-praxis-generation-id")
assert raw.status_code == 200 and reply.choices[0].message.content
assert request_id and generation_id
assert isinstance(usage.get("cost"), (int, float)) and usage["cost"] >= 0
print(reply.choices[0].message.content)
print("usage:", usage)
print("X-Request-Id:", request_id)
print("X-Praxis-Generation-Id:", generation_id)
Path("quickstart-result.json").write_text(json.dumps({
    "request_id": request_id, "generation_id": generation_id, "cost": usage["cost"],
}))
```

Expected: exit code 0, a nonempty reply (usually `Hello Praxis.`), `usage`, two IDs, and a new `quickstart-result.json`. This file contains only the call IDs and cost, never the key.

`usage` includes input and output token counts. `usage.cost` is the amount actually charged in USD, not a price per million tokens. A missing cost does not mean zero. See [Chat Completions API](/docs/api/compatible/openai/createChatCompletion) for field definitions.

## 3. Find this call [#3-find-this-call]

Open [Console → 模型 (Models) → 调用日志 (Call logs)](https://console.deepraxis.ai/call-logs). Paste the previous step’s `X-Request-Id` into “按 X-Request-Id / Generation ID 查找” and press Enter. These Console labels were checked on 2026-10-13.

Expected: the `deepseek-flash` call appears with its status, usage, and cost. Records can take a few seconds to appear. Use the key’s account and environment, with a time range covering the call.

For equivalent verification without a browser, save the following as `verify-generation.py`. In the same directory, run `uv run -q --no-project --with openai --with anthropic --with google-genai python verify-generation.py`.

```python
import json
import os
import time
from decimal import Decimal
from pathlib import Path
import httpx

saved = json.loads(Path("quickstart-result.json").read_text())
base = os.environ.get("PRAXIS_API_BASE", "https://api.deepraxis.com")
with httpx.Client(timeout=60.0) as client:
    for attempt in range(10):
        response = client.get(
            base + "/model/v1/generation",
            params={"id": saved["generation_id"]},
            headers={"Authorization": "Bearer " + os.environ["PRAXIS_API_KEY"]},
        )
        if response.status_code != 404:
            break
        time.sleep(3)
    response.raise_for_status()
    record = response.json()
    assert record["id"] == saved["generation_id"]
    assert record["model"] == "deepseek-flash"
    assert abs(Decimal(str(record["cost"])) - Decimal(str(saved["cost"]))) <= Decimal("0.0000005")
    print("Verified generation:", record["id"])
    print("cost:", record["cost"])
    print("X-Request-Id:", response.headers.get("x-request-id"))
```

Expected: exit code 0, `Verified generation`, and the cost recorded to six decimal places in USD; the script allows for that rounding. This query uses `X-Praxis-Generation-Id`, not `X-Request-Id` or the response body’s `id`. See the [generation record API](/docs/api/native/model/getGeneration).

## Troubleshooting [#troubleshooting]

* `404` when querying a record: the script retries every 3 seconds, up to 10 attempts, while the record becomes available. If it still fails, keep both IDs, check the key, environment, and generation ID belong to this call, then query again.
* `Model "gpt-4o" does not exist.`: model IDs are not automatically mapped. Use `deepseek-flash` or an ID from the [catalog](/docs/developers/model/catalog).

Next, try [streaming](/docs/developers/model/guides/streaming) or [tool calling](/docs/developers/model/guides/tool-calling).

[API reference →](/docs/api/native/model) · [Cookbook →](/docs/cookbook)
