POST /chat request, forwards the message to Together AI’s chat completions API, and returns the model’s reply as JSON. You can follow the guide in TypeScript with Express or in Python with FastAPI.
Both versions call https://api.together.ai/v1/chat/completions, default to Qwen3.5 9B, expose an unauthenticated GET /health endpoint for Render health checks, protect POST /chat with a separate bearer token, and stop an inference request after 60 seconds.
Architecture

CHAT_API_KEY authenticates the caller, and TOGETHER_API_KEY authenticates the server-to-server request to Together AI.
Prerequisites
Before you start, make sure you have:- A Together AI account with an active credit balance.
- A project-scoped Together API key.
- A Render account.
- A GitHub, GitLab, or Bitbucket account.
- Node.js 22 through 24 for the TypeScript path, or Python 3.10 or later for the Python path.
Shell
CHAT_API_KEY. It is different from your TOGETHER_API_KEY.
Step 1: Create the project
Create a new directory and initialize a Git repository:Shell
package.json:
ts/package.json
tsconfig.json:
ts/tsconfig.json
Shell
ts/package-lock.json. The Render build uses npm ci, which requires this file.
For the Python path, create requirements.txt instead:
python/requirements.txt
Shell
Step 2: Add the chat handler
The handler validates the caller before it makes a billable request to Together AI. It also limits the message to 8,000 characters and maps upstream failures to explicit HTTP responses.Step 3: Configure the Render service
Render can create the service from a Blueprint stored inrender.yaml. Create that file in the repository root and use the version for your runtime.
0.0.0.0 so Render can route traffic to it, and it reads the PORT environment variable that Render provides.
The sync: false setting tells Render to prompt for each secret during the initial Blueprint creation instead of storing it in Git. Render does not prompt for these values when it creates a Blueprint preview, so set preview secrets separately if you use preview environments.
Step 4: Deploy the Blueprint
Commit the project and push it to your Git provider:Shell
- Open the Render Dashboard.
- Select New, then Blueprint.
- Connect the repository.
- Enter your Together project API key for
TOGETHER_API_KEY. - Enter the secret you generated earlier for
CHAT_API_KEY. - Select Deploy Blueprint.
https://together-chat-xxxx.onrender.com. The service is ready when the deploy is live and the /health check passes.
A free Render web service spins down after 15 minutes without inbound traffic. Its next request can take about a minute while the service starts again. Use a paid instance if your application needs consistent response latency.
Step 5: Verify the deployment
Save the service URL in your shell:Shell
Shell
Shell
401.
Next, load your CHAT_API_KEY without placing it in your shell history:
Shell
Shell
A non-empty
reply confirms that the client authentication, Render service, Together API key, model ID, and network path all work.Shell
Change the model
The example uses Qwen3.5 9B. To use a different chat model:- Choose a model from the recommended models or the serverless model catalog.
- Open the service in the Render Dashboard.
- Change
TOGETHER_MODELunder Environment. - Save the change and deploy the service.
- Repeat the authenticated verification request.
Extend the app
This guide sends one user message and waits for one complete response. These features require changes to the request schema and the handler:- Multi-turn chat: Accept and validate a
messagesarray instead of a singlemessage. See chat completions. - Streaming: Request
stream: trueand forward the returned stream to the client. The client must also parse streamed events. - Structured JSON: Add a supported response format and schema. See structured outputs.
- Public access: Replace the shared bearer token with user authentication, and add rate limiting, usage monitoring, and abuse controls.
Next steps
Chat completions
Add multi-turn conversations and streaming to the handler.
Structured outputs
Enforce a JSON Schema on the model response.
Render web services
Review instance types, health checks, and scaling on Render.
Batch inference
Process many independent requests offline at lower cost.