Skip to content

Making Your First API Call

Let’s test your API key with a simple request.

Example: Text Generation with Qwen/QwQ-32B

import requests
api_key = "YOUR_API_KEY"
url = "https://api.deeprequest.io/v1/chat/completions"
headers = {
"Content-Type": "application/json",
"Authorization": f"Bearer {api_key}"
}
data = {
"model": "qwq-32b",
"messages": [
{
"role": "user",
"content": "Explain quantum computing in simple terms."
}
],
"max_tokens": 200,
"temperature": 0.7
}
response = requests.post(url, headers=headers, json=data)
print(response.json())
  • Replace YOUR_API_KEY with your actual API key
  • This sends a prompt to Qwen/QwQ-32B and prints the response.

Response Format

The response will be in JSON format:

{
"id": "chatcmpl-123456789",
"object": "chat.completion",
"created": 1704476253,
"model": "qwq-32b",
"choices": [
{
"index": 0,
"message": {
"role": "assistant",
"content": "Quantum computing uses the principles of quantum mechanics to process information. Unlike regular computers that use bits (0s and 1s), quantum computers use quantum bits or 'qubits'. These qubits can exist in multiple states at once through a property called 'superposition', allowing quantum computers to process vast amounts of information simultaneously. This gives them the potential to solve certain complex problems much faster than traditional computers."
},
"finish_reason": "stop"
}
],
"usage": {
"prompt_tokens": 12,
"completion_tokens": 83,
"total_tokens": 95
}
}

Checking for Errors

If your request fails, check:

  1. Your API key is correct
  2. The model name is spelled correctly
  3. Your JSON data is properly formatted

For more examples, see our model documentation.

What’s Next?

  • Dig into other models in Models
  • Learn error handling and optimization in Guides