Skip to main content
Create an Agent, start a Session, and send it a task. Then follow the event stream to read its answer and confirm that the task finished. This example selects Pi with Gemini 2.5 Flash and a Workspace credential you provide. It is one explicit harness/model choice, not a default. For other combinations, see Harnesses and models.
Plain HTTP against the Checkfu API needs no private package. The Checkfu CLI and TypeScript SDK are optional private-alpha artifacts; the HTTP requests work without them. Live readiness is deployment- and Workspace-specific and is not asserted by this page. Confirm capability status before making availability part of your application’s contract.

Before you start

  • A Workspace API key with the admin role. This walkthrough requires it for the Environment permission grant in step 2. See Get access.
  • A Gemini API-key credential in the same Workspace. Add it in Model credentials with provider google-ai-studio, then copy its mcred_… ID. The example pins that credential; it does not assume Checkfu-managed model supply or fall back to it if the key is refused.
  • Workspace execution configured to run Pi with this model. Check the Workspace’s capability status.
  • For the shell examples, Bash, curl, jq, and openssl.
Replace the API key and credential ID below with your own values. The credential ID is a reference, not the provider’s secret key.
Keep CHECKFU_QUICKSTART_ID and each request body unchanged when retrying. Stop if a command fails or does not return an ID; do not run later steps with an empty or old ID. Use this new Session for one task at a time. cURL needs no Checkfu package. The other tabs assume you already installed the CLI or SDK using the instructions supplied with your authorized artifact. See CLI access or the TypeScript SDK reference. For TypeScript, reuse this client and the same request identity:

1. Create an Agent

The Agent selects Pi, Gemini 2.5 Flash, and your credential. Creating it also creates immutable Version 1.
The shell tabs set CHECKFU_AGENT_ID; TypeScript keeps agent.id. See Agents for configuration and versioning.

2. Start a Session

Create an Environment and grant the Agent permission to use it. Then start a Session with that Agent and Environment. The Session records their selected configuration.
The shell tabs set CHECKFU_SESSION_ID; TypeScript keeps session.id. A refused request must be resolved before sending a task; Checkfu does not switch harnesses or model credentials for you.
The embedded agent.version and environment_id identify the immutable AgentVersion and Environment authority frozen at admission.

3. Send a task

Send one message and keep the returned event’s seq. This receipt identifies the accepted input. Authenticated server context supplies durable actor attribution.
The shell tabs set CHECKFU_INPUT_SEQ; TypeScript keeps inputEvent. Retrying this request with the same key and body recovers the same accepted event. Sending a new key would submit another task.

4. Read the answer

Follow from just after the accepted message. The TypeScript example prints the Agent’s answer and only reports success after a normal end-of-turn event. Keep this Session free of other inputs until this task finishes.
Every tab starts after the accepted message’s seq, so earlier history in the Session cannot end the follow. A visible primary agent.message followed by session.status_idle or session.status_completed with stop_reason: "end_turn" marks success for this task. requires_action needs a response before work can continue; failure, cancellation, withheld output, other stop reasons and stream disconnection are not success. The CLI returns at a boundary, including a wait, then prints saved events as JSON so you can inspect payload.stop_reason. cURL stays connected. If the CLI JSON has a non-null next_page, repeat sessions.listEvents with the same --path and --query '{"page":"<next_page>"}', replacing the placeholder with that token and omitting after. Continue until you reach the boundary after the answer; a partial page or [idle] alone does not establish success. With cURL, read the data: payloads and press Ctrl+C after you have checked the answer and boundary. A CLI exit or closed stream alone does not prove success. The SDK preserves the answer flags during automatic reconnects. After a process restart, replay from the original inputEvent.seq unless you restored both answer flags with your cursor. If work requires action, handle the pending approval or tool response and continue reading the same Session. If the connection breaks, resume the stream from the last event you processed; do not create another Session or resend the message to reconnect.
Use the paged event log to inspect persisted history. Follow its pagination to reach the events after your accepted input.

If a request fails

  • 401 auth.invalid_key: check the API key.
  • 400 validation.malformed: check the request body and Checkfu-Version.
  • 404 validation.not_found: check that the resource belongs to the key’s Workspace.
Read the stable error.type in the error reference. Correct the cause before retrying; do not treat every conflict as a stale Agent or switch credentials automatically.

Continue building

Add an agent to your app to send more tasks and show events in your UI. Add tools or context as the work needs them.