- Creates an agent (the model and its instructions).
- Opens a session (a conversation) and sends a first message.
- Waits for the agent to finish its turn.
- Prints the saved conversation.
- Sends a follow-up message in the same conversation.
1
Get your connection details
You need three connection details:Treat the key like a password: keep it in your backend or a secret manager, never in browser code or source control.
- Base URL:
https://api.orcapods.ai/v1. Not/agents, and notapi.openai.com. - API key: create an Orca key in the dashboard under Settings, API keys (it is shown once). An OpenAI key does not work here.
- Model:
orca/openrouter/<OpenRouter id>to run on your Orca credit, or<provider>/<id>with your own provider key. If you are unsure, list the Orca credit models.
2
Install the OpenAI client
Orca works with the official For TypeScript, use Node 22.18+ or Node 24+, which can run
openai package. These docs are tested against the versions below; the Agents API is still a beta, so other versions may differ..ts files directly, or your usual TypeScript runner.3
Write the program
Save this as
quickstart.py or quickstart.ts. The comments mark each of the five steps above. The finally block deletes the agent and session at the end so the demo leaves nothing behind.- Python
- TypeScript
4
Run it
completed, token usage, the conversation (your message and the haiku), and then the follow-up turn completing.What just happened
agents.create saved a configuration. Nothing ran yet, and no tokens were used.
sessions.create with input opened a conversation and sent the first message. The call returned right away, while the agent was still working. That is why the program has a finished() helper: it checks the session’s turn list every half second until the newest turn reaches a final status (completed, failed, or cancelled). Turns and statuses explains why Orca works this way and what each status means.
sessions.items.list read the saved history. The history includes your message, the agent’s reply, and (for agents with tools) every tool call. The list is newest first, so the program reverses it to print in order.
sessions.events.create sent a follow-up message as an input event. Because it is the same session, the agent remembers the poem. The program passes the first turn’s ID to finished() so it waits for the new turn instead of seeing the old one as already done.
Polling is the simplest way to wait. To show the reply word by word as it is generated, use streaming instead.
If something went wrong
More in troubleshooting.
Next steps
Stream responses
Show text as it is generated instead of polling.
Give your agent tools
Let the agent call functions in your code.
Run code in a sandbox
Let the agent run commands and produce files.
How Orca works
The full picture of agents, sessions, turns, and tools.