We’re currently in research preview! We’re excited to share our system with you, and we would love to hear your feedback. If you have thoughts, we’d love to hear from you.
Basic Workflow
- Define your prompt - Describe what you want the agent to accomplish
- Create your tools - Define the functions your agent can use (optional)
- Call the API - Send your request and get intelligent results
Code Examples
Note: TIM models currently require streaming (stream=True) for sync chat completions when using the OpenAI-compatible API.
Example 1: Calling an Agent with No Tools
The simplest use case - just send a prompt and get a response.Example 2: Calling an Agent with One Tool
This example illustrates how tools are defined and passed to the API.Example 3: Calling an Agent with Multiple Tools
This example shows how multiple tools can be composed for more advanced agents.Async workflows
All of the examples above use the sync (blocking) chat completion API. When you have long‑running tasks or want stronger durability guarantees, you can switch to the async flow:- Enqueue work with
POST /v1/chat/completions/async. - Poll job status with
GET /v1/requests/{requestId}/status. - Optionally receive callbacks via webhooks when jobs complete.
Interpreting Results
Because Subconscious uses an OpenAI-compatible API, the response structure follows the standard OpenAI format. When collected into a complete response, the agent’s reasoning and final answer are contained within thechoices[0].message.content field as a JSON object. This field is a string containing structured JSON that represents the agent’s reasoning process and final output.
Response Structure
The object follows this TypeScript interface:Response Fields Explained
reasoning: An array ofTaskobjects that show the agent’s step-by-step reasoning processanswer: The final, human-readable answer to your original prompt
Task Structure
Each task in the reasoning array can contain:thought: The agent’s internal reasoning about what to do nexttitle: A descriptive title for this reasoning steptooluse: Details about a tool call, including:parameters: The input parameters sent to the tooltool_name: The name of the tool that was calledtool_result: The result returned by the tool
subtasks: Nested tasks showing more detailed reasoning stepsconclusion: The agent’s conclusion after completing this reasoning step
Example Response
A simplifiedchoices[0].message.content response will contain JSON like this:
Other Response Fields
The complete API response also includes:usage- Token usage information for the requestmodel- The model that was used for the completion
- Understand how your agent arrives at its final answer
- Debug your agent’s reasoning process
- Monitor tool usage and results
- Optimize your tool configurations