Create LLM chain
create_llm_chainSet up a prompt-to-response LLM chain in TouchDesigner as a self-contained baseCOMP. Supports OpenAI-compatible endpoints (Ollama, OpenAI, Anthropic) and returns paths for container, prompt, response, and status.
Instructions
Stand up a prompt → response LLM chain inside TouchDesigner as a self-contained baseCOMP. Two modes: webclient — stock chain using webclientDAT + textDATs + headers tableDAT that POSTs JSON to any OpenAI-compatible endpoint (OpenAI, Anthropic, Ollama, llama.cpp, LM Studio, OpenRouter). tox_drop — drops the dotsimulate LLM LOPs .tox and wires mirror DATs. Default provider=ollama (fully offline, no key). API keys are read from env inside TouchDesigner (os.environ) and written into a headers tableDAT — the MCP server never sees them. Returns container_path, prompt_dat_path, response_dat_path, status_chan (:busy), provider, model, endpoint_url, and missing_env when a key is needed but unset. Notes: webclientDAT uses reqmethod/url/includeheader (verified live TD 099); body content goes via body_builder textDAT + callbacks. Anthropic uses x-api-key header + anthropic-version, not Authorization; Ollama requires ollama serve running on 127.0.0.1:11434; dotsimulate TOX par names are UNVERIFIED.
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| mode | No | webclient: stock chain via webclientDAT — no extra dependencies, works with any OpenAI-compatible endpoint. tox_drop: drops the dotsimulate LLM LOPs .tox (requires the TOX installed locally). | webclient |
| parent_path | No | COMP path to build inside. | /project1 |
| name | No | Inner baseCOMP name. Defaults to llm_<provider> (webclient) or llm_chain (tox_drop). | |
| provider | No | LLM provider. ollama default — works fully offline, no API key required. custom requires endpoint_url and model. | ollama |
| endpoint_url | No | Override the endpoint URL. Required for provider=custom. Defaults: openai → https://api.openai.com/v1/chat/completions, anthropic → https://api.anthropic.com/v1/messages, ollama → http://127.0.0.1:11434/v1/chat/completions. | |
| model | No | Model name. Required for provider=custom. Defaults: openai → gpt-4o-mini, anthropic → claude-sonnet-4-5, ollama → llama3.2. | |
| system_prompt | No | Written into a hidden sys textDAT. | You are a concise creative assistant for a TouchDesigner live show. |
| initial_prompt | No | Seeds the Prompt textDAT on creation. | |
| max_tokens | No | Maximum tokens in the response. | |
| temperature | No | Sampling temperature [0–2]. | |
| json_mode | No | Set response_format={type:json_object} for openai/ollama compatible endpoints. Ignored for anthropic. | |
| auto_request | No | If true, a datExecuteDAT fires webclient.request() whenever the prompt textDAT changes. Default false — caller drives. | |
| tox_path | No | Path to the dotsimulate LLM TOX. Required for mode=tox_drop. Also probes Library/LLM.tox and tox/LLM.tox. | |
| expose_controls | No | Surface Send (Pulse), Model, Temperature, MaxTokens, Active, JsonMode, Provider on the wrapper. |