GPT4Novel API Documentation
Welcome to the GPT4Novel API documentation. This guide will help you integrate our AI-powered novel writing capabilities into your applications.
Authentication
All API requests require authentication using an API key. You can obtain your API key from your account dashboard after purchasing credits.
Include your API key in the request header:
Authorization: Bearer YOUR_API_KEY
Endpoints
Chat Completions
Generate creative text based on a prompt.
Endpoint: /api/xiaoshuoai/ext/v1/chat/completions
Method: POST
Request Body:
{
"model": "xiaoshuoai-1.0",
"messages": [
{
"role": "system",
"content": "You are a creative fiction writer."
},
{
"role": "user",
"content": "Write the opening paragraph for a science fiction novel about time travel."
}
]
}
Response:
{
"id": "chatcmpl-123456789",
"object": "chat.completion",
"created": 1683123456,
"model": "xiaoshuoai-1.0",
"choices": [
{
"index": 0,
"message": {
"role": "assistant",
"content": "The chronometer on Dr. Eliza Chen's wrist beeped softly as the quantum particles stabilized around her. She had exactly forty-three minutes before the temporal rift would collapse, stranding her in 2157—a full century before she was born. The air smelled different here, lacking the ozone-heavy signature of the climate restoration projects. As she stepped out of the alley, the city skyline—familiar yet alien—sprawled before her, blissfully unaware that their future was now her past, and that she had come to ensure it would never come to be."
},
"finish_reason": "stop"
}
],
"usage": {
"prompt_tokens": 38,
"completion_tokens": 89,
"total_tokens": 127
}
}
Rate Limits
- Free tier: 5 requests per minute
- Standard tier: 60 requests per minute
- Premium tier: 120 requests per minute
Credit Usage
Credits are consumed based on the number of tokens processed:
- 1 credit per 1,000 tokens (both input and output tokens count)
- Minimum charge: 1 credit per request
Model-Specific Credit Costs
- nalang-max-6: High intelligence, good memory, less nonsense (recommended) - 1.5 points/1K tokens
- nalang-medium-2: Stable and reliable medium model - 0.4 points/1K tokens
- nalang-turbo-v19: Previous generation cost performance king - 0.4 points/1K tokens
- nalang-v17-2: Active but disobedient model - 0.2 points/1K tokens
- nalang-xl-11: Latest generation conventional model (recommended) - 0.8 points/1K tokens
- nalang-xl-16k: Suitable for NSFW - 2.0 points/1K tokens
Error Codes
Code | Description |
---|---|
401 | Invalid API key |
402 | Insufficient credits |
429 | Rate limit exceeded |
500 | Server error |
SDKs and Libraries
We provide official client libraries for several programming languages:
Example: Python
import gpt4novel
# Initialize the client
client = gpt4novel.Client(api_key="your_api_key")
# Generate text
response = client.chat.completions.create(
model="xiaoshuoai-1.0",
messages=[
{"role": "system", "content": "You are a creative fiction writer."},
{"role": "user", "content": "Write a short story about a robot learning to paint."}
]
)
# Print the response
print(response.choices[0].message.content)
Need Help?
If you have any questions or need assistance, please contact our support team .