XPULINK AI Model API Quick Start Guide¶
This guide will help you quickly get started with the XPULINK AI platform's cloud-based model API. We'll use Python and the requests library to call the qwen3-32b model.
Prerequisites¶
- Python 3.7+
- requests library (
pip install requests) - XPULINK AI platform account and API Key
Configuration Steps¶
1. Obtain API Key¶
- Log in to XPULINK AI platform (https://www.xpulink.ai)
- Get your API Key from the user center
- Set the API Key as an environment variable
2. Set Environment Variable¶
# Linux/Mac
export XPULINK_API_KEY="your_api_key_here"
# Windows
set XPULINK_API_KEY=your_api_key_here
3. Model Information¶
- Model Name: qwen3-32b
- API Endpoint: https://www.xpulink.ai/v1/chat/completions
- Request Method: POST
- Authentication: Bearer Token
Complete Code Example¶
The following code demonstrates how to call XPULINK AI's cloud-based model for conversation:
import os
import requests
# Read API Key from environment variable
API_KEY = os.getenv("XPULINK_API_KEY")
if not API_KEY:
raise ValueError("Please set XPULINK_API_KEY in environment variables")
# Cloud model API information
MODEL_NAME = "qwen3-32b"
BASE_URL = "https://www.xpulink.ai/v1/chat/completions"
# Construct request headers
headers = {
"Authorization": f"Bearer {API_KEY}",
"Content-Type": "application/json"
}
# Construct request body
payload = {
"model": MODEL_NAME,
"messages": [
{"role": "user", "content": "Hello, please briefly introduce yourself."}
],
"max_tokens": 50,
"temperature": 0.7
}
# Send request and print result
try:
response = requests.post(BASE_URL, headers=headers, json=payload, timeout=30)
response.raise_for_status()
result = response.json()
print("Model response:", result["choices"][0]["message"]["content"])
print("Test passed! Cloud model is working correctly.")
except Exception as e:
print("Test failed:", e)
Parameter Description¶
Request Parameters¶
model: Model name, using "qwen3-32b" heremessages: Array of conversation messages, containing role and contentmax_tokens: Maximum number of tokens to generate, controls response lengthtemperature: Temperature parameter, controls randomness (0-1), higher values mean more random
Response Format¶
A successful response returns JSON formatted data with main fields including:
- choices[0].message.content: Model-generated response content
- usage: Token usage statistics
- model: Name of the model used
Running the Test¶
Save the code as test_xpulink.py and run:
python test_xpulink.py
If configured correctly, you will see the model's self-introduction response and a success message.
Troubleshooting¶
Common Errors¶
- API Key Error: Ensure environment variable is set correctly
- Network Timeout: Check network connection, or increase timeout value
- Permission Error: Confirm API Key is valid and has sufficient quota
Debugging Tips¶
- Print complete error messages for more details
- Use curl command to test API connectivity
- Check XPULINK platform status page
Extended Usage¶
Based on this basic example, you can:
- Modify messages content for multi-turn conversations
- Adjust temperature parameter to control response style
- Add system role messages to set system prompts
- Include additional request parameters like top_p, frequency_penalty, etc.