{"openapi":"3.1.0","info":{"title":"TengoChat API","version":"1.0","description":"TengoChat's AI in your apps: OpenAI-compatible chat completions, agents with tools and connectors, files and usage.","contact":{"url":"https://tengochat.com/developers/support"}},"servers":[{"url":"https://tengochat.com/api/v1"}],"security":[{"bearer":[]}],"components":{"securitySchemes":{"bearer":{"type":"http","scheme":"bearer","description":"Your API key (tc_live_...), made in Create, Developers."}}},"paths":{"/models":{"get":{"operationId":"models","summary":"List models","description":"The models you can call, with their price in credits per million tokens.","tags":["Models"],"responses":{"200":{"description":"OK","content":{"application/json":{"example":{"object":"list","data":[{"id":"tengo-1","object":"model","name":"Tengo 1","context_window":128000,"pricing":{"unit":"credits per million tokens","input":1000,"output":4000}}]}}}},"401":{"description":"No key, or a key that does not work"},"402":{"description":"Out of credits"},"429":{"description":"Too many requests"}}}},"/chat/completions":{"post":{"operationId":"chat","summary":"Create a chat completion","description":"OpenAI-compatible. Send messages, get the answer, or stream it with \"stream\": true.","tags":["Chat"],"responses":{"200":{"description":"OK","content":{"application/json":{"example":{"id":"chatcmpl-9f2c","object":"chat.completion","model":"tengo-1","choices":[{"index":0,"message":{"role":"assistant","content":"Merge at five p.m.\nThe pager hums all weekend.\nMonday has questions."},"finish_reason":"stop"}],"usage":{"prompt_tokens":31,"completion_tokens":17,"total_tokens":48,"credits":1}}}}},"401":{"description":"No key, or a key that does not work"},"402":{"description":"Out of credits"},"429":{"description":"Too many requests"}},"requestBody":{"required":true,"content":{"application/json":{"schema":{"type":"object","required":["messages"],"properties":{"model":{"type":"string"},"messages":{"type":"array","items":{"type":"object","required":["role","content"],"properties":{"role":{"type":"string","enum":["system","user","assistant"]},"content":{"type":"string"}}}},"max_tokens":{"type":"integer"},"temperature":{"type":"number"},"stream":{"type":"boolean"}}},"example":{"model":"tengo-1","messages":[{"role":"system","content":"You are a concise assistant."},{"role":"user","content":"Write a haiku about shipping on Friday."}]}}}}}},"/agents":{"get":{"operationId":"agents_list","summary":"List agents","description":"The agents on your account.","tags":["Agents"],"responses":{"200":{"description":"OK","content":{"application/json":{"example":{"object":"list","data":[{"id":"ag_3f1a9c2b7d6e5f40","object":"agent","name":"Support helper","model":"tengo-1","tools":["files"],"memory":true}]}}}},"401":{"description":"No key, or a key that does not work"},"402":{"description":"Out of credits"},"429":{"description":"Too many requests"}}}},"/agents/{agent_id}":{"get":{"operationId":"agents_get","summary":"Get an agent","description":"One agent, with its tools and connectors.","tags":["Agents"],"responses":{"200":{"description":"OK","content":{"application/json":{"example":{"id":"ag_3f1a9c2b7d6e5f40","object":"agent","name":"Support helper","model":"tengo-1","tools":["files"],"connectors":[],"memory":true,"public":false}}}},"401":{"description":"No key, or a key that does not work"},"402":{"description":"Out of credits"},"429":{"description":"Too many requests"}},"parameters":[{"name":"agent_id","in":"path","required":true,"description":"The agent id, like ag_3f1a9c2b7d6e5f40.","schema":{"type":"string"}}]}},"/agents/{agent_id}/messages":{"post":{"operationId":"agents_message","summary":"Message an agent","description":"The agent reads the thread, uses its tools and connectors, and answers. Leave thread_id out to start a new thread; send it back to continue.","tags":["Agents"],"responses":{"200":{"description":"OK","content":{"application/json":{"example":{"id":"msg_a81c","object":"agent.message","agent_id":"ag_3f1a9c2b7d6e5f40","thread_id":"th_5d0c2e7a","content":"Two pull requests are waiting: #42 (login fix) and #45 (new pricing page).","tools_used":["github_list_pulls"],"usage":{"input_tokens":812,"output_tokens":64,"credits":3}}}}},"401":{"description":"No key, or a key that does not work"},"402":{"description":"Out of credits"},"429":{"description":"Too many requests"}},"parameters":[{"name":"agent_id","in":"path","required":true,"description":"The agent id.","schema":{"type":"string"}}],"requestBody":{"required":true,"content":{"application/json":{"schema":{"type":"object","required":["message"],"properties":{"message":{"type":"string"},"thread_id":{"type":"string"},"user":{"type":"string"},"stream":{"type":"boolean"}}},"example":{"message":"Which pull requests need a review?","user":"customer-4821"}}}}}},"/threads/{thread_id}":{"get":{"operationId":"threads_get","summary":"Get a thread","description":"Everything said in a thread.","tags":["Agents"],"responses":{"200":{"description":"OK","content":{"application/json":{"example":{"id":"th_5d0c2e7a","object":"thread","agent_id":"ag_3f1a9c2b7d6e5f40","messages":[{"role":"user","content":"Hi"},{"role":"assistant","content":"Hello! How can I help?"}]}}}},"401":{"description":"No key, or a key that does not work"},"402":{"description":"Out of credits"},"429":{"description":"Too many requests"}},"parameters":[{"name":"thread_id","in":"path","required":true,"description":"The thread id.","schema":{"type":"string"}}]},"delete":{"operationId":"threads_delete","summary":"Delete a thread","description":"Forget a thread and its messages for good.","tags":["Agents"],"responses":{"200":{"description":"OK","content":{"application/json":{"example":{"id":"th_5d0c2e7a","object":"thread","deleted":true}}}},"401":{"description":"No key, or a key that does not work"},"402":{"description":"Out of credits"},"429":{"description":"Too many requests"}},"parameters":[{"name":"thread_id","in":"path","required":true,"description":"The thread id.","schema":{"type":"string"}}]}},"/files":{"get":{"operationId":"files_list","summary":"List files","description":"Your stored files, newest first, and how much room is used.","tags":["Files"],"responses":{"200":{"description":"OK","content":{"application/json":{"example":{"object":"list","data":[{"id":"file_6a1f0e9b2c3d4e5f6a7b","object":"file","name":"handbook.md","bytes":18342,"visibility":"private"}],"storage":{"plan":"free","used_bytes":18342,"quota_bytes":268435456}}}}},"401":{"description":"No key, or a key that does not work"},"402":{"description":"Out of credits"},"429":{"description":"Too many requests"}},"parameters":[{"name":"q","in":"query","required":false,"description":"Only names containing this.","schema":{"type":"string"}},{"name":"limit","in":"query","required":false,"description":"Up to 1,000. Default 100.","schema":{"type":"string"}}]},"post":{"operationId":"files_upload","summary":"Upload a file","description":"multipart/form-data with the file in \"file\". Public files get a permanent tengochat.com address; private ones a link that lasts an hour.","tags":["Files"],"responses":{"200":{"description":"OK","content":{"application/json":{"example":{"id":"file_6a1f0e9b2c3d4e5f6a7b","object":"file","name":"logo.png","bytes":48211,"mime":"image/png","visibility":"public","url":"https://tengochat.com/f/file_6a1f0e9b2c3d4e5f6a7b/logo.png"}}}},"401":{"description":"No key, or a key that does not work"},"402":{"description":"Out of credits"},"429":{"description":"Too many requests"}},"requestBody":{"required":true,"content":{"multipart/form-data":{"schema":{"type":"object","required":["file"],"properties":{"file":{"type":"string","format":"binary"},"visibility":{"type":"string","enum":["private","public"]},"name":{"type":"string"}}}}}}}},"/files/{file_id}":{"get":{"operationId":"files_get","summary":"Get a file","description":"A file and its address.","tags":["Files"],"responses":{"200":{"description":"OK","content":{"application/json":{"example":{"id":"file_6a1f0e9b2c3d4e5f6a7b","object":"file","url":"https://tengochat.com/f/file_6a1f0e9b2c3d4e5f6a7b/logo.png?e=1763341200&s=..."}}}},"401":{"description":"No key, or a key that does not work"},"402":{"description":"Out of credits"},"429":{"description":"Too many requests"}},"parameters":[{"name":"file_id","in":"path","required":true,"description":"The file id.","schema":{"type":"string"}}]},"post":{"operationId":"files_update","summary":"Change a file","description":"Make it public or private.","tags":["Files"],"responses":{"200":{"description":"OK","content":{"application/json":{"example":{"id":"file_6a1f0e9b2c3d4e5f6a7b","object":"file","visibility":"public"}}}},"401":{"description":"No key, or a key that does not work"},"402":{"description":"Out of credits"},"429":{"description":"Too many requests"}},"parameters":[{"name":"file_id","in":"path","required":true,"description":"The file id.","schema":{"type":"string"}}],"requestBody":{"required":true,"content":{"application/json":{"schema":{"type":"object"},"example":{"visibility":"public"}}}}},"delete":{"operationId":"files_delete","summary":"Delete a file","description":"Gone for good, and its room is free again.","tags":["Files"],"responses":{"200":{"description":"OK","content":{"application/json":{"example":{"id":"file_6a1f0e9b2c3d4e5f6a7b","object":"file","deleted":true}}}},"401":{"description":"No key, or a key that does not work"},"402":{"description":"Out of credits"},"429":{"description":"Too many requests"}},"parameters":[{"name":"file_id","in":"path","required":true,"description":"The file id.","schema":{"type":"string"}}]}},"/files/{file_id}/content":{"get":{"operationId":"files_content","summary":"Download a file","description":"Redirects to the file itself.","tags":["Files"],"responses":{"200":{"description":"OK"},"401":{"description":"No key, or a key that does not work"},"402":{"description":"Out of credits"},"429":{"description":"Too many requests"}},"parameters":[{"name":"file_id","in":"path","required":true,"description":"The file id.","schema":{"type":"string"}}]}},"/usage":{"get":{"operationId":"usage","summary":"Credits and usage","description":"Credits left, spent this month, the last 30 days day by day, and storage.","tags":["Account"],"responses":{"200":{"description":"OK","content":{"application/json":{"example":{"object":"usage","credits":18450,"credits_usd":18.45,"this_month":{"credits":3120},"last_30_days":{"calls":1204,"credits":4580}}}}},"401":{"description":"No key, or a key that does not work"},"402":{"description":"Out of credits"},"429":{"description":"Too many requests"}}}}}}