🚀 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 including vision capabilities, function calling, and streaming responses.
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
Available Models
You can list available models using these endpoints:
- Text Models:
GET /text/models
- Image Models:
GET /image/models
Popular Models:
Image Models: Multiple image generation models supported
Audio Voices: alloy, echo, fable, nova, onyx, shimmer
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 (optional) | None |
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 (optional) | None |
width |
integer | Image width (64-2048) | 768 |
height |
integer | Image height (64-2048) | 768 |
model |
string | Model to use (flux/turbo/kontext) | 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
Vision Capabilities
Analyze images using vision-capable models through OpenAI-compatible interface.
Supported Models:
openai
- Standard vision modelopenai-large
- Enhanced vision modelclaude-hybridspace
- Claude vision model
Example Request:
curl -X POST "https://dynaspark.onrender.com/api/openai" \
-H "Content-Type: application/json" \
-d '{
"model": "openai",
"messages": [
{
"role": "user",
"content": [
{"type": "text", "text": "What is in this image?"},
{
"type": "image_url",
"image_url": {
"url": "https://example.com/image.jpg"
}
}
]
}
],
"max_tokens": 300
}'
OpenAI Compatible Endpoint
Full OpenAI-compatible chat completions endpoint supporting advanced features like function calling, streaming, and multimodal inputs.
Features:
- Chat completions with message history
- Function calling capabilities
- Streaming responses
- Vision (image analysis)
- Speech-to-text transcription
- JSON mode responses
Basic Chat Example:
curl -X POST "https://dynaspark.onrender.com/api/openai" \
-H "Content-Type: application/json" \
-d '{
"model": "openai",
"messages": [
{"role": "system", "content": "You are a helpful assistant."},
{"role": "user", "content": "What is the capital of France?"}
],
"temperature": 0.7
}'
Streaming Response:
curl -X POST "https://dynaspark.onrender.com/api/openai" \
-H "Content-Type: application/json" \
-d '{
"model": "openai",
"messages": [
{"role": "user", "content": "Tell me a story"}
],
"stream": true
}'
Or Use it with OpenAI Python Package:
from openai import OpenAI
# Configure OpenAI client
client = OpenAI(
base_url="https://dynaspark.onrender.com/openai",
api_key="Th3-C0der", # No API key required but required by OpenAI client so use any random string
)
# Use it like regular OpenAI API
completion = client.chat.completions.create(
model="openai",
messages=[
{"role": "user", "content": "What is the meaning of life?"}
]
)
print(completion.choices[0].message.content)
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"
Streaming Response:
curl -N "https://dynaspark.onrender.com/api/generate_response?user_input=Tell%20me%20a%20long%20story&stream=true"
With System Prompt:
curl "https://dynaspark.onrender.com/api/generate_response?user_input=Hello&system=You%20are%20a%20pirate%20assistant"
Image Generation Examples
Basic Image:
curl "https://dynaspark.onrender.com/api/generate_image?user_input=A%20cute%20cat%20playing%20with%20yarn&model=flux" --output cat.jpg
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" --output landscape.jpg
Image-to-Image Generation:
curl "https://dynaspark.onrender.com/api/generate_image?user_input=Transform%20this%20into%20a%20painting&model=kontext&image=https://example.com/input.jpg" --output transformed.jpg
With Seed for Reproducibility:
curl "https://dynaspark.onrender.com/api/generate_image?user_input=A%20serene%20forest&seed=12345&model=flux" --output forest.jpg
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
Additional Endpoints
Model Listing
Returns a list of available text generation models.
Returns a list of available image generation models.
Real-time Feeds
Server-sent events stream of real-time text generations.
Server-sent events stream of real-time image generations.
Direct Endpoints
Direct text generation.
Direct image generation.
Example Direct Usage:
# Direct text generation
curl "https://dynaspark.onrender.com/api/text/What%20is%20AI?model=openai"
# Direct image generation
curl "https://dynaspark.onrender.com/api/image/A%20beautiful%20sunset?width=1024&height=768" --output sunset.jpg
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.
What models are available?
The API provides access to various models including OpenAI, Mistral, Claude, and specialized models for coding, search, and image generation. Use the model listing endpoints to see current availability.
Does it support streaming?
Yes! Both the GET endpoint (with stream=true
) and POST endpoint support streaming
responses via Server-Sent Events.