Skip to Content
Assistant Core

Developer API quickstart

Create an API key and get your first assistant response from the Developer API in about five minutes.

This tutorial takes you from no key to a first chat response, then continues the same conversation. Run it from a terminal or a backend, never from a browser console.

Before you begin

  • You are the Assistant Owner. Every plan can use the Developer API, Free included.
  • The owner has credits left; each response uses them.
  • You have curl, Python 3.8+, or Node.js 18+.

Create an API key

  1. Open the Admin Panel and select the assistant.
  2. In the sidebar, select Developer API.
  3. Select Create API key.
  4. Enter a Key name, for example Quickstart, and under Scopes select only Chat (chat:write).
  5. Select Create API key, then Copy API key, and select I've saved the key.

The key starts with ac_ and is shown only once. If you lose it, rotate the key to get a replacement (see API keys and security).

Set environment variables

export ASSISTANT_API_URL="https://api.assistantcore.com"
export ASSISTANT_API_KEY="<your-api-key>"
export EXTERNAL_USER_ID="customer_42"

The Developer API page shows the base URL under API base URL. external_user_id is your own ID for the end user: 1–256 characters, stable for the same person, and free of emails, phone numbers, or secrets.

Send your first request

curl "$ASSISTANT_API_URL/v1/responses" \
  --request POST \
  --header "Authorization: Bearer $ASSISTANT_API_KEY" \
  --header "Content-Type: application/json" \
  --header "Idempotency-Key: $(uuidgen)" \
  --data "{
    \"external_user_id\": \"$EXTERNAL_USER_ID\",
    \"input\": \"Summarize your return policy.\"
  }"

A successful call returns 200:

{
  "id": "resp_5f0c2a9e8b7d4c1fa3e6b2d9c8a7f104",
  "object": "response",
  "status": "completed",
  "conversation_id": "a12d5e41-7ab7-4c8f-b024-c2c38b5c43f4",
  "model": "gemini-3.8-flash",
  "output_text": "Our return policy allows...",
  "message_id": "b0f16c77-a275-46c8-9dc8-8fe9fd5991cc",
  "request_id": "3f9a1c0b7d2e"
}

If you get an error instead, the body has a code. The most common ones on a first call:

CodeFix
INVALID_API_KEYThe key is missing, mistyped, or truncated. Copy it again or rotate it.
INSUFFICIENT_SCOPEThe key lacks chat:write. Create a key with the Chat scope.
INSUFFICIENT_CREDITSThe owner is out of credits.

All codes are in Errors and limits.

Continue the conversation

Send the conversation_id from the first response, the same external_user_id, and a new Idempotency-Key:

curl "$ASSISTANT_API_URL/v1/responses" \
  --request POST \
  --header "Authorization: Bearer $ASSISTANT_API_KEY" \
  --header "Content-Type: application/json" \
  --header "Idempotency-Key: $(uuidgen)" \
  --data "{
    \"external_user_id\": \"$EXTERNAL_USER_ID\",
    \"conversation_id\": \"<conversation-id>\",
    \"input\": \"Does that apply to sale items?\"
  }"

The assistant answers with the earlier turn in context. Another external_user_id gets 404 CONVERSATION_NOT_FOUND for this conversation.

Move the call into your backend

In production, your backend makes the call and derives external_user_id from its own sign-in session. This Next.js route handler is one way to do it; replace getAuthenticatedUserId() with your auth helper.

app/api/assistant/chat/route.ts
export async function POST(request: Request) {
  const externalUserId = await getAuthenticatedUserId(request)
  if (!externalUserId) {
    return Response.json({ error: "Unauthorized" }, { status: 401 })
  }

  const { input, conversationId } = await request.json()
  const response = await fetch(`${process.env.ASSISTANT_API_URL}/v1/responses`, {
    method: "POST",
    headers: {
      Authorization: `Bearer ${process.env.ASSISTANT_API_KEY}`,
      "Content-Type": "application/json",
      "Idempotency-Key": crypto.randomUUID(),
    },
    body: JSON.stringify({
      external_user_id: externalUserId,
      conversation_id: conversationId,
      input,
    }),
  })

  return Response.json(await response.json(), { status: response.status })
}

Before going live:

  • Grant each key only the scopes it needs, and use a separate assistant and key for staging (Preview has no sandbox; staging calls use real credits).
  • Set an HTTP timeout and retry only when retryable is true, reusing the same Idempotency-Key for the same operation.
  • Log X-Request-ID with the status code; never log the API key.

Last updated on