Getting started

Quickstart: your first Claude request in five minutes

Create a SubToAPI account, connect Claude once, create an application API key and send your first request to https://api.subtoapi.app/v1/messages — with curl, TypeScript, Python or PHP.

Updated

SubToAPI puts a clean HTTPS API in front of your Claude access. Your apps talk to https://api.subtoapi.app with a SubToAPI application key; the dashboard handles the connection, keys, usage metadata and your team. This page gets you from zero to a real answer.

1. Create an account and connect Claude

  1. Create a free account — the trial runs 14 days, no credit card.
  2. Open Connection in the dashboard and follow the guided steps. The connection lives server-side; your browser and your apps never see provider credentials.
  3. Wait for the status pill to show Connected. The dashboard keeps the connection alive for you.

2. Create an application API key

Go to Integrate → API keys, give the key a name (one key per app is a good habit) and copy it once — it is shown exactly one time. Keys look like sub_live_… and are stored only as hashes.

.env
SUBTOAPI_URL="https://api.subtoapi.app"
SUBTOAPI_KEY="$SUBTOAPI_KEY"

3. Send a request

Every call is plain JSON over HTTPS with a Bearer header. Pick a model alias — fast, balanced or best — and send your messages.

terminal
curl -X POST \
  "https://api.subtoapi.app/v1/messages" \
  -H "Authorization: Bearer $SUBTOAPI_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "system": "You are a helpful assistant.",
    "messages": [
      { "role": "user", "content": "Hello" }
    ],
    "model": "balanced"
  }'
ask.ts
const SUBTOAPI_URL = "https://api.subtoapi.app";
const SUBTOAPI_KEY = process.env.SUBTOAPI_KEY!; // never hardcode

export async function ask(prompt: string) {
  const res = await fetch(`${SUBTOAPI_URL}/v1/messages`, {
    method: "POST",
    headers: {
      Authorization: `Bearer ${SUBTOAPI_KEY}`,
      "Content-Type": "application/json",
    },
    body: JSON.stringify({
      system: "You are a helpful assistant.",
      messages: [{ role: "user", content: prompt }],
      model: "balanced",
    }),
  });

  const data = await res.json();
  if (!res.ok) throw new Error(`${data.error}: ${data.message}`);
  return data;
}
ask.py
import os, requests

SUBTOAPI_URL = "https://api.subtoapi.app"
SUBTOAPI_KEY = os.environ["SUBTOAPI_KEY"]

r = requests.post(
    f"{SUBTOAPI_URL}/v1/messages",
    headers={"Authorization": f"Bearer {SUBTOAPI_KEY}"},
    json={
        "system": "You are a helpful assistant.",
        "messages": [{"role": "user", "content": "Hello"}],
        "model": "fast",
    },
    timeout=120,
)
data = r.json()
if not r.ok:
    raise RuntimeError(f"{data['error']}: {data['message']}")
print(data["content"][0]["text"])
ask.php
<?php
$apiUrl = "https://api.subtoapi.app";
$key = getenv("SUBTOAPI_KEY"); // never hardcode

$payload = [
  "system" => "You are a helpful assistant.",
  "messages" => [
    ["role" => "user", "content" => "Hello"],
  ],
  "model" => "balanced",
];

$ch = curl_init("$apiUrl/v1/messages");
curl_setopt_array($ch, [
  CURLOPT_POST           => true,
  CURLOPT_RETURNTRANSFER => true,
  CURLOPT_HTTPHEADER     => [
    "Authorization: Bearer $key",
    "Content-Type: application/json",
  ],
  CURLOPT_POSTFIELDS     => json_encode($payload),
]);

$raw = curl_exec($ch);
$status = curl_getinfo($ch, CURLINFO_HTTP_CODE);
curl_close($ch);

$data = json_decode($raw, true);
if ($status !== 200) {
  throw new RuntimeException($data["error"] . ": " . $data["message"]);
}

echo $data["content"][0]["text"], PHP_EOL;

4. Read the response

The answer is normalized: an array of content blocks plus token counts, latency, the resolved model and a request id you can quote to support.

response.json
{
  "id": "msg_...",
  "provider": "claude",
  "model": "balanced",
  "content": [
    { "type": "text", "text": "Hello! How can I help you today?" }
  ],
  "usage": {
    "input_tokens": 2510,
    "output_tokens": 74,
    "cache_read_tokens": 2048,
    "cache_write_tokens": 0,
    "total_tokens": 2584
  },
  "latency_ms": 842,
  "request_id": "req_..."
}

That's it

You are calling Claude through your own API. Next: multi-turn conversations, streaming and tool use.

Frequently asked questions

Do I need an SDK?
No. Anything that can send an HTTPS POST with a JSON body works — curl, fetch, requests, Guzzle, serverless functions, cron jobs.
Which model should I start with?
balanced is the default and a good first choice. Use fast for lightweight tasks and best for hard reasoning.
Does the trial include the API?
Yes. The 14-day trial includes the dashboard, API keys and the public API with trial rate limits.