🚀 DynaSpark API
A powerful, free API for text, image, and audio generation - No API key required! 🆓
Getting Started
Overview
The DynaSpark API provides powerful AI capabilities for text generation, image creation, and audio synthesis. It's designed to be easy to use while offering advanced features for developers.
Authentication
While authentication is optional, you can include an API key in your requests:
curl "https://dynaspark.onrender.com/api/generate_response?user_input=Hello%20world&api_key=YOUR_API_KEY"
Base URL
All API endpoints are relative to the base URL:
https://dynaspark.onrender.com/api
Endpoints
Text Generation
Generate text responses using various models and parameters.
Parameters:
Parameter | Type | Description | Default |
---|---|---|---|
user_input |
string | The input text to generate a response for | Required |
api_key |
string | Your API key | Required |
model |
string | Model to use for generation | None |
temperature |
float | Controls randomness (0.0-3.0) | None |
top_p |
float | Controls diversity (0.0-1.0) | None |
presence_penalty |
float | Penalizes repeated tokens (-2.0-2.0) | None |
frequency_penalty |
float | Penalizes frequent tokens (-2.0-2.0) | None |
json |
boolean | Return JSON response | false |
system |
string | Custom system prompt | None |
stream |
boolean | Stream the response | false |
private |
boolean | Keep generation private | false |
seed |
integer | Random seed for reproducibility | None |
referrer |
string | Referrer information | None |
voice |
string | Voice for audio response | None |
Example Request:
curl "https://dynaspark.onrender.com/api/generate_response?user_input=Hello%20world&temperature=0.8"
Image Generation
Generate images from text descriptions.
Parameters:
Parameter | Type | Description | Default |
---|---|---|---|
user_input |
string | The prompt to generate an image for | Required |
api_key |
string | Your API key | Required |
width |
integer | Image width (64-2048) | 768 |
height |
integer | Image height (64-2048) | 768 |
model |
string | Model to use (flux/turbo/gptimage) | None |
nologo |
boolean | Exclude watermark | false |
seed |
integer | Random seed | None |
wm |
string | Custom watermark | None |
Example Request:
curl "https://dynaspark.onrender.com/api/generate_image?user_input=A%20serene%20mountain%20landscape&width=1024&height=768&model=flux&nologo=true"
Audio Generation
Generate audio responses from text using various voices.
Parameters:
Parameter | Type | Description | Default |
---|---|---|---|
user_input |
string | The text to convert to speech | Required |
api_key |
string | Your API key (optional) | None |
model |
string | Must be "openai-audio" | Required |
voice |
string | Voice to use (alloy/echo/fable/nova/onyx/shimmer) | alloy |
speed |
float | Speech speed (0.25-4.0) | 1.0 |
format |
string | Output format (mp3/aac/flac) | mp3 |
quality |
string | Audio quality (standard/hd) | standard |
Example Request:
curl "https://dynaspark.onrender.com/api/generate_response?user_input=Hello%20world&model=openai-audio&voice=nova" --output response.mp3
Response Formats
Text Generation Response
By default, the API returns the generated text directly:
Request:
curl "https://dynaspark.onrender.com/api/generate_response?user_input=Hello"
Response:
Hello! How can I assist you today?
When using json=true
, the response format varies based on the type of request:
Regular Text Response:
Request:
curl "https://dynaspark.onrender.com/api/generate_response?user_input=Hello&json=true"
Response:
{
"message": "Hello! How can I assist you today?"
}
List Response:
Request:
curl "https://dynaspark.onrender.com/api/generate_response?user_input=List%203%20Pokemons&json=true"
Response:
{
"Pokemons": ["Pikachu", "Charmander", "Bulbasaur", "Squirtle"]
}
- Regular text responses use the
message
field - List responses use a field name matching the request (e.g.,
Pokemons
,colors
, etc.) - The response structure is optimized for the type of content being generated
Image Generation Response
{
"image_url": "https://dynaspark.onrender.com/image/A%20serene%20mountain%20landscape?width=1024&model=flux&nologo=true"
}
Audio Generation Response
Audio responses are returned as binary MP3 data with Content-Type: audio/mpeg
curl "https://dynaspark.onrender.com/api/generate_response?user_input=Hello&model=openai-audio&voice=nova" --output response.mp3
Error Handling
The API uses standard HTTP status codes and returns error details in the response body:
Status Code | Description |
---|---|
400 |
Bad Request - Invalid parameters |
401 |
Unauthorized - Invalid API key |
429 |
Too Many Requests - Rate limit exceeded |
500 |
Internal Server Error |
Error Response Example:
{
"error": {
"code": "rate_limit_exceeded",
"message": "Rate limit exceeded. Try again in 60 seconds.",
"details": {
"reset_time": "2024-01-01T00:01:00Z"
}
}
}
Rate Limits
The API implements rate limiting to ensure fair usage:
Free Tier Limits
- 100 requests per hour
- Maximum 10 concurrent requests
- Rate limit headers included in responses
Rate Limit Headers
Header | Description |
---|---|
X-RateLimit-Limit |
Total requests allowed per hour |
X-RateLimit-Remaining |
Remaining requests in current hour |
X-RateLimit-Reset |
Time when rate limit resets (Unix timestamp) |
Examples
Text Generation Examples
Basic Text Generation:
curl "https://dynaspark.onrender.com/api/generate_response?user_input=Explain%20quantum%20computing%20in%20simple%20terms&model=mistral&temperature=0.7"
Code Generation:
curl "https://dynaspark.onrender.com/api/generate_response?user_input=Write%20a%20Python%20function%20to%20sort%20a%20list%20of%20dictionaries%20by%20a%20key&model=qwen-coder&temperature=0.2"
JSON Response:
curl "https://dynaspark.onrender.com/api/generate_response?user_input=List%203%20colors&json=true"
Image Generation Examples
Basic Image:
curl "https://dynaspark.onrender.com/api/generate_image?user_input=A%20cute%20cat%20playing%20with%20yarn&model=flux"
High-Resolution Image:
curl "https://dynaspark.onrender.com/api/generate_image?user_input=A%20detailed%20landscape%20of%20mountains%20at%20sunset&width=1024&height=768&model=turbo&nologo=true"
Audio Generation Examples
Basic Audio:
curl "https://dynaspark.onrender.com/api/generate_response?user_input=Welcome%20to%20DynaSpark!%20This%20is%20a%20test%20of%20the%20audio%20generation.&model=openai-audio&voice=alloy" --output response.mp3
Multiple Voices:
# Generate audio with different voices
for voice in "alloy" "echo" "nova"; do
curl "https://dynaspark.onrender.com/api/generate_response?user_input=This%20is%20voice%20$voice&model=openai-audio&voice=$voice" --output "voice_${voice}.mp3"
done
Troubleshooting
Common Issues
Rate Limit Exceeded
If you see a rate limit error, wait for the reset time or reduce your request frequency.
Image Generation Fails
If image generation fails, check that your prompt is appropriate and within the allowed parameters.
Audio Generation Issues
If audio generation fails, ensure your text is not too long and contains valid characters.
FAQ
Frequently Asked Questions
Do I need an API key?
No, currently no API key is required to use the API. You can start using it right away!
What are the rate limits?
Free usage is limited to 100 requests per hour. Contact us for higher limits.
Can I use this in production?
Yes, the API is stable and suitable for production use. However, consider getting a custom API key for higher rate limits.