A simple web server for stream processing your prompts with LLMS
- Clone the repository
- Install the dependencies:
pip install -r requirements.txt - Configure your environment variables in
.env:# Authentication API_TOKEN=your_secure_token # API Keys ANTHROPIC_API_KEY=your_anthropic_api_key GOOGLE_API_KEY=your_google_api_key # Server configuration PORT=3000
The server will start on port 3000 by default (can be changed in .env file). In development it uses another port due to conflict with cockpit. Use the provided bin/dev-server script to start the server in development mode.
POST /stream
Processes a prompt and streams response to prevent timeouts.
Bearer token authentication is required. Include an Authorization header with the format: Bearer your_token, where your_token matches the API_TOKEN value set in the .env file.
Example:
Authorization: Bearer your_secure_token
{
"model": "gpt-4o",
"prompt": "Your instructions..."
}model: The AI model to use for processing. Please refer to the provider's documentation for available models.prompt: Instructions or text to be processed
References:
{
"result": "processed_definition_here"
}GET /health
Returns a simple health status to check if the server is running.
{
"status": "healthy"
}The API returns appropriate HTTP status codes and error messages:
400 Bad Request: Missing required parameters401 Unauthorized: Missing or invalid Bearer token500 Internal Server Error: Server-side processing errors
curl -X POST http://localhost:5500/stream \
-H "Authorization: Bearer your_secure_token" \
-H "Content-Type: application/json" \
-d '{
"model": "gpt-4o",
"prompt": "Your instructions..."
}'