POST /api/generate

Generate text completions using AI models

This endpoint generates text completions based on the provided prompt and model. It's ideal for single-turn conversations, content generation, and text completion tasks.

Request Parameters

Parameter Type Required Description
model string Required The model ID to use for generation (e.g., "qwen2.5:1.5b", "llama3.2:3b")
prompt string Required The input text prompt for generation
stream boolean Required Whether to stream the response (true) or return complete response (false)
options object Optional Additional generation parameters
system string Optional System message to set model behavior
template string Optional Prompt template to use
context array Optional Context from previous generations

Request Example

POST https://ai.itways.in/api/generate Content-Type: application/json { "model": "qwen2.5:1.5b", "prompt": "Explain the concept of artificial intelligence in simple terms:", "stream": false, "options": { "temperature": 0.7, "top_p": 0.9, "max_tokens": 500 } }

Response

{ "model": "qwen2.5:1.5b", "created_at": "2025-10-24T12:00:00.000Z", "response": "Artificial intelligence (AI) is the simulation of human intelligence processes by machines, especially computer systems. These processes include learning, reasoning, and self-correction. In simple terms, AI allows computers to think and learn like humans, enabling them to perform tasks that typically require human intelligence such as recognizing speech, making decisions, and solving problems.", "done": true, "context": [1234, 5678, ...], "total_duration": 1250000000, "load_duration": 50000000, "prompt_eval_count": 15, "prompt_eval_duration": 100000000, "eval_count": 45, "eval_duration": 1100000000 }

Try It Out

POST /api/chat

Chat completion with conversational AI

Use this endpoint for multi-turn conversations with the AI model.

Request Example

{ "model": "qwen2.5:1.5b", "messages": [ { "role": "user", "content": "Hello, how are you?" } ], "stream": false }
GET /api/tags

List available models

Retrieve a list of all available AI models on the server.

Response Example

{ "models": [ { "name": "qwen2.5:1.5b", "model": "qwen2.5:1.5b", "size": 986061892, "details": { "format": "gguf", "family": "qwen2", "parameter_size": "1.5B", "quantization_level": "Q4_K_M" } } ] }
GET /api/models

Get detailed model information

Retrieve detailed information about a specific model.

Authentication

Currently, the IT Ways AI API does not require authentication. All endpoints are publicly accessible. However, we recommend implementing rate limiting in your application.

Rate Limiting

To ensure fair usage and system stability, the following rate limits apply:

  • 100 requests per hour per IP address
  • 10 concurrent requests per IP address
  • Large models may have additional processing time limits

Error Handling

The API uses standard HTTP status codes and returns error messages in JSON format:

Common Error Codes

Code Description
400 Bad Request - Invalid parameters
404 Not Found - Model or endpoint not found
429 Too Many Requests - Rate limit exceeded
500 Internal Server Error

Error Response Example

{ "error": "model 'unknown-model' not found", "code": 404 }