An open-source API built with Cloudflare Workers + OpenAI Assistant API, using TypeScript and Hono. This is version 1 of a growing project. Created on April 30, 2025.

It lets you consume a custom OpenAI Assistant from any frontend, using simple endpoints: /thread and /chat. It's designed as a base for financial bots, educational assistants, or any AI-powered project.
- A Cloudflare account.
- An OpenAI account.
- At least $5 USD in your OpenAI billing.
- Node.js and npm installed locally.
git clone https://github.com/your-username/quantix-ai-assistant-api.git
cd quantix-ai-assistant-apinpm install- Register or log in to Cloudflare.
- Install Wrangler CLI globally:
npm install -g wrangler- If needed, authenticate Wrangler:
wrangler login- Go to platform.openai.com.
- Add billing credit.
- Navigate to Assistants and create a new one.
- Choose any model (e.g.,
gpt-3.5-turbo). - Copy the generated
assistant_id.
- Choose any model (e.g.,
Run the following in your terminal:
wrangler secret put OPENAI_API_KEY
wrangler secret put ASSISTANT_IDMake sure your API key and Assistant ID are correct.
wrangler devThis will start your Worker at http://localhost:8787, where you can test your API using Postman, curl, or your frontend.
Creates a new assistant thread.
Example request:
GET http://localhost:8787/threadExample response:
{
"thread_id": "thread_mKpjEzSnWnS6Id81voNxzpBI"
}Sends a message to the assistant and receives a response based on a thread.
Request URL:
POST http://localhost:8787/chatRequest Body:
{
"message": "Who are you?",
"thread_id": "thread_mKpjEzSnWnS6Id81voNxzpBI",
"limit": 1
}message: (string) The user message to send.thread_id: (string) The thread ID returned by/thread.limit: (optional, number) Limits how many messages are returned (default is all).
Example response:
[
{
"content": "I was built using OpenAI's Assistant API and deployed with Cloudflare Workers"
}
]When you're ready to go live:
wrangler deployYour API will be deployed to a Cloudflare URL.
src/
├── index.ts # Entry point with Hono
├── routes/
│ ├── chat.ts # POST /chat
│ └── thread.ts # GET /thread
├── utils/
│ └── openai.ts # OpenAI client
├── middlewares/
│ └── cors.ts # CORS headers
├── types/
│ └── index.ts # Request types
MIT © Hensell Espinoza