Getting Started with the Subconscious API 🧠

Learn how to use the Subconscious AI agent API on Val Town.

Setup

  1. Get an API key from the Subconscious platform
  2. Add it as an environment variable in this val's settings: SUBCONSCIOUS_API_KEY

Examples

Each file demonstrates a different way to use the Subconscious SDK:

FileTypeDescription
01_script.tsScriptSimplest example — run a one-shot agent query
02_http.tsHTTPExpose an AI search agent as an HTTP API endpoint
03_cron.tsCronRun a scheduled agent task on an interval
04_email.tsEmailProcess incoming emails with an AI agent

Key Concepts

Engines

EngineDescription
tim-edgeFast & efficient, tuned for search tools
tim-gptRecommended for most use cases
tim-gpt-heavyMaximum capability for complex tasks

Tools

Tools extend what the agent can do. Three types:

  • Platform tools — hosted by Subconscious (e.g. fast_search, deep_search)
  • Function tools — your own HTTP endpoints the agent can call
  • MCP tools — connect to any MCP server

Structured Output

Use answerFormat with a Zod schema + zodToJsonSchema() to get typed JSON responses.