Constructor
Create a new instance of the Thred API client.Parameters
Configuration object for the Thred client
Examples
Basic Configuration
Custom Model and Timeout
Environment Variables
Configuration Best Practices
API Key Security
- Never hardcode your API key in source code
- Use environment variables or secure configuration management
- Keep your API key confidential and rotate it regularly
Model Selection
Choose your default model based on your use case:- gpt-4: Use for complex reasoning, detailed analysis, or when quality is paramount
- gpt-4-turbo: Balance of speed and capability for most production use cases
- gpt-3.5-turbo: Use for simple tasks, high-volume requests, or cost optimization
Timeout Configuration
Set timeouts based on your expected response times:- Short timeouts (10-20s) for simple queries
- Medium timeouts (30-45s) for standard use cases (default)
- Long timeouts (60s+) for complex analysis or streaming responses
Error Handling
The constructor will throw an error if the API key is not provided:Related
- answer() - Generate AI responses
- answerStream() - Stream AI responses with callback
- answerStreamGenerator() - Stream with async generators
