Spaces:
Running
import requests
Browse filesimport json
import time
from typing import Dict, Any, Optional, Iterator, List, Union
from dataclasses import dataclass, field
from urllib.parse import urlencode, quote
@dataclass
class Message:
"""Represents a chat message"""
role: str
content: Union[str, List[Dict[str, Any]]]
@dataclass
class ChatCompletionChunk:
"""Represents a streaming chunk from the API"""
id: str
object: str
created: int
model: str
choices: List[Dict[str, Any]]
system_fingerprint: Optional[str] = None
prompt_filter_results: Optional[List[Dict[str, Any]]] = None
def get_content(self) -> str:
"""Extract content from the first choice delta"""
if self.choices and len(self.choices) > 0:
delta = self.choices[0].get('delta', {})
return delta.get('content', '')
return ''
def is_finished(self) -> bool:
"""Check if this chunk indicates completion"""
if self.choices and len(self.choices) > 0:
return self.choices[0].get('finish_reason') is not None
return False
class PollinationClient:
"""Enhanced client for interacting with pollinations.ai API, with improved features and support for more endpoints."""
def __init__(
self,
base_url: str = "https://text.pollinations.ai/openai/v1/chat/completions",
token: Optional[str] = None,
referrer: Optional[str] = None
):
self.base_url = base_url.rstrip('/')
self.token = token
self.referrer = referrer
self.session = requests.Session()
if self.token:
self.session.headers.update({"Authorization": f"Bearer {self.token}"})
def _parse_sse_line(self, line: str) -> Optional[Dict[str, Any]]:
"""Parse a single SSE line"""
line = line.strip()
if not line or line.startswith(':'):
return None
if line.startswith('data: '):
data_str = line[6:] # Remove 'data: ' prefix
if data_str.strip() == '[DONE]':
return {'done': True}
try:
return json.loads(data_str)
except json.JSONDecodeError:
return None
return None
def chat_completion(
self,
messages: List[Message],
model: str = "gpt-4o",
stream: bool = True,
temperature: float = 0.7,
max_tokens: Optional[int] = 12000,
top_p: Optional[float] = None,
frequency_penalty: Optional[float] = None,
presence_penalty: Optional[float] = None,
stop: Optional[List[str]] = None,
seed: Optional[int] = None,
response_format: Optional[Dict[str, str]] = None,
tools: Optional[List[Dict[str, Any]]] = None,
tool_choice: Optional[Union[str, Dict[str, Any]]] = None,
private: bool = False,
**kwargs
) -> Iterator[ChatCompletionChunk]:
"""
Create a chat completion with streaming support. Enhanced with support for multimodal inputs (vision, audio),
tools, JSON mode, seed, private mode, and more.
Args:
messages: List of Message objects (content can be str or list for multimodal)
model: Model to use (default: gpt-4o, other options like mistral, claude-hybridspace)
stream: Whether to stream responses (default: True)
temperature: Sampling temperature (default: 0.7)
max_tokens: Maximum tokens to generate
top_p: Top-p sampling parameter
frequency_penalty: Frequency penalty
presence_penalty: Presence penalty
stop: Stop sequences
seed: Seed for reproducible results
response_format: Response format, e.g., {"type": "json_object"} for JSON mode
tools: List of tools for function calling
tool_choice: Tool choice configuration
private: If True, prevent response from appearing in public feed
**kwargs: Additional parameters
Yields:
ChatCompletionChunk objects
"""
# Convert messages to the format expected by the API
formatted_messages = []
for msg in messages:
formatted_messages.append({
"role": msg.role,
"content": msg.content
})
# Build query parameters
params = {
"model": model,
"stream": str(stream).lower(),
"temperature": temperature,
"private": str(private).lower(),
}
if self.token:
params["token"] = self.token
if self.referrer:
params["referrer"] = self.referrer
# Add optional parameters
if max_tokens is not None:
params["max_tokens"] = max_tokens
if top_p is not None:
params["top_p"] = top_p
if frequency_penalty is not None:
params["frequency_penalty"] = frequency_penalty
if presence_penalty is not None:
params["presence_penalty"] = presence_penalty
if stop is not None:
params["stop"] = stop
if seed is not None:
params["seed"] = seed
# Add any additional kwargs
params.update(kwargs)
# Build URL with query parameters
query_string = urlencode(params, doseq=True)
url = f"{self.base_url}?{query_string}"
# Prepare request body
payload = {
"messages": formatted_messages
}
if response_format:
payload["response_format"] = response_format
if tools:
payload["tools"] = tools
if tool_choice:
payload["tool_choice"] = tool_choice
# Make streaming request
headers = {
"Content-Type": "application/json",
"Accept": "text/event-stream"
}
try:
response = self.session.post(
url,
json=payload,
headers=headers,
stream=True,
timeout=30
)
response.raise_for_status()
# Process streaming response
for line in response.iter_lines(decode_unicode=True):
if not line:
continue
parsed = self._parse_sse_line(line)
if parsed is None:
continue
if parsed.get('done'):
break
# Convert to ChatCompletionChunk
chunk = ChatCompletionChunk(
id=parsed.get('id', ''),
object=parsed.get('object', ''),
created=parsed.get('created', 0),
model=parsed.get('model', ''),
choices=parsed.get('choices', []),
system_fingerprint=parsed.get('system_fingerprint'),
prompt_filter_results=parsed.get('prompt_filter_results')
)
yield chunk
# Check if completion is finished
if chunk.is_finished():
break
except requests.RequestException as e:
raise ConnectionError(f"Failed to connect to Pollination API: {e}")
except Exception as e:
raise RuntimeError(f"Error processing response: {e}")
def chat_completion_simple(
self,
prompt: str,
model: str = "gpt-4o",
temperature: float = 0.7,
**kwargs
) -> str:
"""
Simple chat completion that returns the full response as a string
Args:
prompt: The prompt to send
model: Model to use
temperature: Sampling temperature
**kwargs: Additional parameters
Returns:
Complete response as a string
"""
messages = [Message(role="user", content=prompt)]
response_content = ""
for chunk in self.chat_completion(
messages=messages,
model=model,
temperature=temperature,
**kwargs
):
response_content += chunk.get_content()
return response_content.strip()
def list_models(self) -> List[Dict[str, Any]]:
"""List available text models"""
url = "https://text.pollinations.ai/models"
response = self.session.get(url)
response.raise_for_status()
return response.json()
def generate_image(
self,
prompt: str,
model: str = "flux",
width: int = 1024,
height: int = 1024,
seed: Optional[int] = None,
nologo: bool = False,
private: bool = False,
enhance: bool = False,
safe: bool = False
) -> bytes:
"""Generate an image and return the image bytes"""
params = {
"model": model,
"width": width,
"height": height,
"seed": seed if seed is not None else "random",
"nologo": str(nologo).lower(),
"private": str(private).lower(),
"enhance": str(enhance).lower(),
"safe": str(safe).lower(),
}
encoded_prompt = quote(prompt)
query_string = urlencode(params)
url = f"https://pollinations.ai/p/{encoded_prompt}?{query_string}"
response = self.session.get(url)
response.raise_for_status()
return response.content
def text_to_speech(
self,
prompt: str,
model: str = "openai-audio",
voice: str = "nova"
) -> bytes:
"""Generate speech audio from text and return audio bytes"""
encoded_prompt = quote(prompt)
params = {
"model": model,
"voice": voice,
}
query_string = urlencode(params)
url = f"https://text.pollinations.ai/{encoded_prompt}?{query_string}"
response = self.session.get(url)
response.raise_for_status()
return response.content
# Helper functions
def create_message(role: str, content: Union[str, List[D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
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
<!DOCTYPE html>
|
| 2 |
+
<html lang="en">
|
| 3 |
+
<head>
|
| 4 |
+
<meta charset="UTF-8">
|
| 5 |
+
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
| 6 |
+
<title>API Documentation | Vibecode Studio</title>
|
| 7 |
+
<link rel="icon" type="image/x-icon" href="data:image/svg+xml,<svg xmlns=%22http://www.w3.org/2000/svg%22 viewBox=%220 0 100 100%22><text y=%22.9em%22 font-size=%2290%22>🔌</text></svg>">
|
| 8 |
+
<script src="https://cdn.tailwindcss.com"></script>
|
| 9 |
+
<script src="https://unpkg.com/feather-icons"></script>
|
| 10 |
+
<script>
|
| 11 |
+
tailwind.config = {
|
| 12 |
+
theme: {
|
| 13 |
+
extend: {
|
| 14 |
+
colors: {
|
| 15 |
+
primary: '#6366f1',
|
| 16 |
+
secondary: '#8b5cf6',
|
| 17 |
+
accent: '#ec4899',
|
| 18 |
+
dark: '#0f172a',
|
| 19 |
+
light: '#f8fafc'
|
| 20 |
+
}
|
| 21 |
+
}
|
| 22 |
+
}
|
| 23 |
+
}
|
| 24 |
+
</script>
|
| 25 |
+
<style>
|
| 26 |
+
@import url('https://fonts.googleapis.com/css2?family=Inter:wght@300;400;500;600;700&display=swap');
|
| 27 |
+
body {
|
| 28 |
+
font-family: 'Inter', sans-serif;
|
| 29 |
+
background-color: #0f172a;
|
| 30 |
+
}
|
| 31 |
+
.glow {
|
| 32 |
+
box-shadow: 0 0 15px rgba(99, 102, 241, 0.5);
|
| 33 |
+
}
|
| 34 |
+
.feature-card:hover {
|
| 35 |
+
transform: translateY(-5px);
|
| 36 |
+
transition: all 0.3s ease;
|
| 37 |
+
}
|
| 38 |
+
.code-block {
|
| 39 |
+
background: #1e293b;
|
| 40 |
+
border-radius: 0.5rem;
|
| 41 |
+
padding: 1rem;
|
| 42 |
+
font-family: 'Monaco', 'Menlo', 'Ubuntu Mono', monospace;
|
| 43 |
+
font-size: 0.875rem;
|
| 44 |
+
line-height: 1.5;
|
| 45 |
+
overflow-x: auto;
|
| 46 |
+
}
|
| 47 |
+
.endpoint-card {
|
| 48 |
+
transition: all 0.3s ease;
|
| 49 |
+
}
|
| 50 |
+
.endpoint-card:hover {
|
| 51 |
+
transform: translateX(5px);
|
| 52 |
+
}
|
| 53 |
+
.tab-active {
|
| 54 |
+
border-bottom: 2px solid #6366f1;
|
| 55 |
+
color: #6366f1;
|
| 56 |
+
}
|
| 57 |
+
</style>
|
| 58 |
+
</head>
|
| 59 |
+
<body class="text-light">
|
| 60 |
+
<!-- Navigation -->
|
| 61 |
+
<nav class="fixed w-full z-50 bg-dark/90 backdrop-blur-sm py-4 px-6 flex justify-between items-center">
|
| 62 |
+
<div class="flex items-center space-x-2">
|
| 63 |
+
<div class="w-10 h-10 rounded-full bg-gradient-to-r from-primary to-accent flex items-center justify-center">
|
| 64 |
+
<i data-feather="code" class="text-white"></i>
|
| 65 |
+
</div>
|
| 66 |
+
<span class="text-xl font-bold">Vibecode<span class="text-accent">Studio</span></span>
|
| 67 |
+
</div>
|
| 68 |
+
<div class="hidden md:flex space-x-8">
|
| 69 |
+
<a href="index.html" class="hover:text-primary transition">Home</a>
|
| 70 |
+
<a href="#" class="hover:text-primary transition">Features</a>
|
| 71 |
+
<a href="#" class="hover:text-primary transition">API</a>
|
| 72 |
+
<a href="chat.html" class="hover:text-primary transition">Chat</a>
|
| 73 |
+
</div>
|
| 74 |
+
<div class="flex items-center space-x-4">
|
| 75 |
+
<button class="px-4 py-2 rounded-lg bg-primary hover:bg-primary/80 transition">Get Started</button>
|
| 76 |
+
<button id="menu-toggle" class="md:hidden text-light">
|
| 77 |
+
<i data-feather="menu"></i>
|
| 78 |
+
</button>
|
| 79 |
+
</div>
|
| 80 |
+
</nav>
|
| 81 |
+
|
| 82 |
+
<!-- Hero Section -->
|
| 83 |
+
<section class="pt-24 pb-12">
|
| 84 |
+
<div class="container mx-auto px-6">
|
| 85 |
+
<div class="text-center max-w-3xl mx-auto">
|
| 86 |
+
<h1 class="text-4xl md:text-5xl font-bold mb-6">
|
| 87 |
+
Powerful <span class="text-primary">API</span> Integration
|
| 88 |
+
</h1>
|
| 89 |
+
<p class="text-xl text-gray-300 mb-8">
|
| 90 |
+
Integrate Vibecode Studio into your applications with our comprehensive API.
|
| 91 |
+
Generate code, create images, and convert text to speech programmatically.
|
| 92 |
+
</p>
|
| 93 |
+
<div class="flex flex-col sm:flex-row justify-center gap-4">
|
| 94 |
+
<button class="px-6 py-3 rounded-lg bg-primary hover:bg-primary/80 transition font-medium glow">
|
| 95 |
+
Get API Key
|
| 96 |
+
</button>
|
| 97 |
+
<button class="px-6 py-3 rounded-lg bg-dark border border-gray-700 hover:bg-gray-800 transition font-medium">
|
| 98 |
+
View Examples
|
| 99 |
+
</button>
|
| 100 |
+
</div>
|
| 101 |
+
</div>
|
| 102 |
+
</div>
|
| 103 |
+
</section>
|
| 104 |
+
|
| 105 |
+
<!-- API Endpoints Section -->
|
| 106 |
+
<section class="py-12 bg-dark/50">
|
| 107 |
+
<div class="container mx-auto px-6">
|
| 108 |
+
<div class="text-center mb-12">
|
| 109 |
+
<h2 class="text-3xl font-bold mb-4">API <span class="text-primary">Endpoints</span></h2>
|
| 110 |
+
<p class="text-gray-400 max-w-2xl mx-auto">
|
| 111 |
+
Explore our available API endpoints and their capabilities
|
| 112 |
+
</p>
|
| 113 |
+
</div>
|
| 114 |
+
|
| 115 |
+
<div class="grid grid-cols-1 lg:grid-cols-3 gap-8">
|
| 116 |
+
<!-- Endpoint 1 -->
|
| 117 |
+
<div class="endpoint-card bg-dark border border-gray-800 rounded-2xl p-6">
|
| 118 |
+
<div class="flex items-start mb-4">
|
| 119 |
+
<div class="w-10 h-10 rounded-lg bg-primary/10 flex items-center justify-center mr-3">
|
| 120 |
+
<i data-feather="message-square" class="text-primary"></i>
|
| 121 |
+
</div>
|
| 122 |
+
<div>
|
| 123 |
+
<h3 class="text-xl font-bold">Chat Completion</h3>
|
| 124 |
+
<span class="text-sm bg-gray-800 text-gray-400 px-2 py-1 rounded">POST</span>
|
| 125 |
+
</div>
|
| 126 |
+
</div>
|
| 127 |
+
<p class="text-gray-400 mb-4">
|
| 128 |
+
Generate conversational AI responses with streaming support
|
| 129 |
+
</p>
|
| 130 |
+
<div class="text-sm font-mono bg-gray-900 p-3 rounded">
|
| 131 |
+
/openai/v1/chat/completions
|
| 132 |
+
</div>
|
| 133 |
+
</div>
|
| 134 |
+
|
| 135 |
+
<!-- Endpoint 2 -->
|
| 136 |
+
<div class="endpoint-card bg-dark border border-gray-800 rounded-2xl p-6">
|
| 137 |
+
<div class="flex items-start mb-4">
|
| 138 |
+
<div class="w-10 h-10 rounded-lg bg-accent/10 flex items-center justify-center mr-3">
|
| 139 |
+
<i data-feather="image" class="text-accent"></i>
|
| 140 |
+
</div>
|
| 141 |
+
<div>
|
| 142 |
+
<h3 class="text-xl font-bold">Image Generation</h3>
|
| 143 |
+
<span class="text-sm bg-gray-800 text-gray-400 px-2 py-1 rounded">GET</span>
|
| 144 |
+
</div>
|
| 145 |
+
</div>
|
| 146 |
+
<p class="text-gray-400 mb-4">
|
| 147 |
+
Create stunning images from text prompts
|
| 148 |
+
</p>
|
| 149 |
+
<div class="text-sm font-mono bg-gray-900 p-3 rounded">
|
| 150 |
+
/p/{prompt}
|
| 151 |
+
</div>
|
| 152 |
+
</div>
|
| 153 |
+
|
| 154 |
+
<!-- Endpoint 3 -->
|
| 155 |
+
<div class="endpoint-card bg-dark border border-gray-800 rounded-2xl p-6">
|
| 156 |
+
<div class="flex items-start mb-4">
|
| 157 |
+
<div class="w-10 h-10 rounded-lg bg-secondary/10 flex items-center justify-center mr-3">
|
| 158 |
+
<i data-feather="mic" class="text-secondary"></i>
|
| 159 |
+
</div>
|
| 160 |
+
<div>
|
| 161 |
+
<h3 class="text-xl font-bold">Text to Speech</h3>
|
| 162 |
+
<span class="text-sm bg-gray-800 text-gray-400 px-2 py-1 rounded">GET</span>
|
| 163 |
+
</div>
|
| 164 |
+
</div>
|
| 165 |
+
<p class="text-gray-400 mb-4">
|
| 166 |
+
Convert text to natural sounding speech
|
| 167 |
+
</p>
|
| 168 |
+
<div class="text-sm font-mono bg-gray-900 p-3 rounded">
|
| 169 |
+
/{prompt}
|
| 170 |
+
</div>
|
| 171 |
+
</div>
|
| 172 |
+
</div>
|
| 173 |
+
</div>
|
| 174 |
+
</section>
|
| 175 |
+
|
| 176 |
+
<!-- JavaScript SDK Section -->
|
| 177 |
+
<section class="py-20">
|
| 178 |
+
<div class="container mx-auto px-6">
|
| 179 |
+
<div class="flex flex-col lg:flex-row items-center gap-12">
|
| 180 |
+
<div class="lg:w-1/2">
|
| 181 |
+
<h2 class="text-3xl font-bold mb-6">
|
| 182 |
+
JavaScript <span class="text-primary">SDK</span>
|
| 183 |
+
</h2>
|
| 184 |
+
<p class="text-gray-400 mb-6">
|
| 185 |
+
Our JavaScript SDK makes it easy to integrate Vibecode Studio into your web applications.
|
| 186 |
+
With built-in support for streaming responses, image generation, and text-to-speech.
|
| 187 |
+
</p>
|
| 188 |
+
|
| 189 |
+
<div class="flex space-x-4 mb-8">
|
| 190 |
+
<button id="sdk-tab" class="tab-active px-4 py-2 font-medium">SDK</button>
|
| 191 |
+
<button id="fetch-tab" class="px-4 py-2 font-medium">Fetch API</button>
|
| 192 |
+
</div>
|
| 193 |
+
|
| 194 |
+
<ul class="space-y-4 mb-8">
|
| 195 |
+
<li class="flex items-start">
|
| 196 |
+
<i data-feather="check-circle" class="text-green-500 mt-1 mr-3"></i>
|
| 197 |
+
<span>Streaming chat completions</span>
|
| 198 |
+
</li>
|
| 199 |
+
<li class="flex items-start">
|
| 200 |
+
<i data-feather="check-circle" class="text-green-500 mt-1 mr-3"></i>
|
| 201 |
+
<span>Image generation with text prompts</span>
|
| 202 |
+
</li>
|
| 203 |
+
<li class="flex items-start">
|
| 204 |
+
<i data-feather="check-circle" class="text-green-500 mt-1 mr-3"></i>
|
| 205 |
+
<span>Text-to-speech conversion</span>
|
| 206 |
+
</li>
|
| 207 |
+
<li class="flex items-start">
|
| 208 |
+
<i data-feather="check-circle" class="text-green-500 mt-1 mr-3"></i>
|
| 209 |
+
<span>Promise-based async/await support</span>
|
| 210 |
+
</li>
|
| 211 |
+
</ul>
|
| 212 |
+
|
| 213 |
+
<button class="px-6 py-3 rounded-lg bg-primary hover:bg-primary/80 transition font-medium">
|
| 214 |
+
Download SDK
|
| 215 |
+
</button>
|
| 216 |
+
</div>
|
| 217 |
+
|
| 218 |
+
<div class="lg:w-1/2 w-full">
|
| 219 |
+
<div class="bg-dark border border-gray-800 rounded-2xl p-6">
|
| 220 |
+
<div class="flex justify-between items-center mb-4">
|
| 221 |
+
<div class="text-sm text-gray-400">JavaScript Example</div>
|
| 222 |
+
<div class="flex space-x-2">
|
| 223 |
+
<button class="px-3 py-1 text-xs rounded bg-primary/10 text-primary">JavaScript</button>
|
| 224 |
+
</div>
|
| 225 |
+
</div>
|
| 226 |
+
<div class="code-block">
|
| 227 |
+
<pre class="text-blue-400"><span class="text-blue-400">import</span> { <span class="text-yellow-300">PollinationClient</span> } <span class="text-blue-400">from</span> <span class="text-green-400">'@vibecode/sdk'</span>;</pre>
|
| 228 |
+
<pre class="text-gray-400"></pre>
|
| 229 |
+
<pre class="text-blue-400"><span class="text-blue-400">const</span> client = <span class="text-yellow-300">new</span> <span class="text-yellow-300">PollinationClient</span>({</pre>
|
| 230 |
+
<pre class="text-blue-400"> apiKey: <span class="text-green-400">'your-api-key'</span></pre>
|
| 231 |
+
<pre class="text-blue-400">});</pre>
|
| 232 |
+
<pre class="text-gray-400"></pre>
|
| 233 |
+
<pre class="text-blue-400"><span class="text-blue-400">const</span> response = <span class="text-yellow-300">await</span> client.chatCompletion({</pre>
|
| 234 |
+
<pre class="text-blue-400"> messages: [{</pre>
|
| 235 |
+
<pre class="text-blue-400"> role: <span class="text-green-400">'user'</span>,</pre>
|
| 236 |
+
<pre class="text-blue-400"> content: <span class="text-green-400">'Create a responsive navbar with Tailwind'</span></pre>
|
| 237 |
+
<pre class="text-blue-400"> }],</pre>
|
| 238 |
+
<pre class="text-blue-400"> model: <span class="text-green-400">'gpt-4o'</span></pre>
|
| 239 |
+
<pre class="text-blue-400">});</pre>
|
| 240 |
+
<pre class="text-gray-400"></pre>
|
| 241 |
+
<pre class="text-blue-400"><span class="text-yellow-300">console</span>.<span class="text-yellow-300">log</span>(response.choices[0].message.content);</pre>
|
| 242 |
+
</div>
|
| 243 |
+
</div>
|
| 244 |
+
</div>
|
| 245 |
+
</div>
|
| 246 |
+
</div>
|
| 247 |
+
</section>
|
| 248 |
+
|
| 249 |
+
<!-- API Examples Section -->
|
| 250 |
+
<section class="py-20 bg-dark/50">
|
| 251 |
+
<div class="container mx-auto px-6">
|
| 252 |
+
<div class="text-center mb-16">
|
| 253 |
+
<h2 class="text-3xl font-bold mb-4">API <span class="text-primary">Examples</span></h2>
|
| 254 |
+
<p class="text-gray-400 max-w-2xl mx-auto">
|
| 255 |
+
See how easy it is to integrate Vibecode Studio into your applications
|
| 256 |
+
</p>
|
| 257 |
+
</div>
|
| 258 |
+
|
| 259 |
+
<div class="grid grid-cols-1 md:grid-cols-2 gap-8">
|
| 260 |
+
<!-- Example 1 -->
|
| 261 |
+
<div class="bg-dark border border-gray-800 rounded-2xl p-6">
|
| 262 |
+
<h3 class="text-xl font-bold mb-4 flex items-center">
|
| 263 |
+
<i data-feather="message-circle" class="text-primary mr-2"></i>
|
| 264 |
+
Chat Completion
|
| 265 |
+
</h3>
|
| 266 |
+
<div class="code-block mb-4">
|
| 267 |
+
<pre class="text-blue-400"><span class="text-blue-400">const</span> response = <span class="text-yellow-300">await</span> fetch(<span class="text-green-400">'https://text.pollinations.ai/openai/v1/chat/completions'</span>, {</pre>
|
| 268 |
+
<pre class="text-blue-400"> method: <span class="text-green-400">'POST'</span>,</pre>
|
| 269 |
+
<pre class="text-blue-400"> headers: {</pre>
|
| 270 |
+
<pre class="text-blue-400"> <span class="text-green-400">'Content-Type'</span>: <span class="text-green-400">'application/json'</span></pre>
|
| 271 |
+
<pre class="text-blue-400"> },</pre>
|
| 272 |
+
<pre class="text-blue-400"> body: <span class="text-yellow-300">JSON</span>.<span class="text-yellow-300">stringify</span>({</pre>
|
| 273 |
+
<pre class="text-blue-400"> messages: [{</pre>
|
| 274 |
+
<pre class="text-blue-400"> role: <span class="text-green-400">'user'</span>,</pre>
|
| 275 |
+
<pre class="text-blue-400"> content: <span class="text-green-400">'Explain quantum computing in simple terms'</span></pre>
|
| 276 |
+
<pre class="text-blue-400"> }]</pre>
|
| 277 |
+
<pre class="text-blue-400"> })</pre>
|
| 278 |
+
<pre class="text-blue-400">});</pre>
|
| 279 |
+
</div>
|
| 280 |
+
<p class="text-gray-400">
|
| 281 |
+
Generate conversational AI responses with our chat completion endpoint.
|
| 282 |
+
</p>
|
| 283 |
+
</div>
|
| 284 |
+
|
| 285 |
+
<!-- Example 2 -->
|
| 286 |
+
<div class="bg-dark border border-gray-800 rounded-2xl p-6">
|
| 287 |
+
<h3 class="text-xl font-bold mb-4 flex items-center">
|
| 288 |
+
<i data-feather="image" class="text-accent mr-2"></i>
|
| 289 |
+
Image Generation
|
| 290 |
+
</h3>
|
| 291 |
+
<div class="code-block mb-4">
|
| 292 |
+
<pre class="text-blue-400"><span class="text-blue-400">const</span> imageUrl = <span class="text-green-400">'https://pollinations.ai/p/A beautiful sunset?model=flux&width=1024&height=1024'</span>;</pre>
|
| 293 |
+
<pre class="text-gray-400"></pre>
|
| 294 |
+
<pre class="text-blue-400"><span class="text-blue-400">const</span> response = <span class="text-yellow-300">await</span> fetch(imageUrl);</pre>
|
| 295 |
+
<pre class="text-blue-400"><span class="text-blue-400">const</span> imageBlob = <span class="text-yellow-300">await</span> response.blob();</pre>
|
| 296 |
+
<pre class="text-gray-400"></pre>
|
| 297 |
+
<pre class="text-blue-400"><span class="text-blue-400">const</span> imageUrl = <span class="text-yellow-300">URL</span>.<span class="text-yellow-300">createObjectURL</span>(imageBlob);</pre>
|
| 298 |
+
<pre class="text-blue-400"><span class="text-yellow-300">document</span>.<span class="text-yellow-300">getElementById</span>(<span class="text-green-400">'image'</span>).src = imageUrl;</pre>
|
| 299 |
+
</div>
|
| 300 |
+
<p class="text-gray-400">
|
| 301 |
+
Create stunning images from text prompts with our image generation API.
|
| 302 |
+
</p>
|
| 303 |
+
</div>
|
| 304 |
+
</div>
|
| 305 |
+
</div>
|
| 306 |
+
</section>
|
| 307 |
+
|
| 308 |
+
<!-- CTA Section -->
|
| 309 |
+
<section class="py-20">
|
| 310 |
+
<div class="container mx-auto px-6 text-center">
|
| 311 |
+
<h2 class="text-3xl md:text-4xl font-bold mb-6">
|
| 312 |
+
Start Building with <span class="text-primary">Vibecode API</span>
|
| 313 |
+
</h2>
|
| 314 |
+
<p class="text-gray-400 max-w-2xl mx-auto mb-8">
|
| 315 |
+
Get your API key and start integrating powerful AI capabilities into your applications today.
|
| 316 |
+
</p>
|
| 317 |
+
<div class="flex flex-col sm:flex-row justify-center space-y-4 sm:space-y-0 sm:space-x-4">
|
| 318 |
+
<button class="px-8 py-3 rounded-lg bg-primary hover:bg-primary/80 transition font-medium glow">
|
| 319 |
+
Get API Key
|
| 320 |
+
</button>
|
| 321 |
+
<button class="px-8 py-3 rounded-lg bg-dark border border-gray-700 hover:bg-gray-800 transition font-medium">
|
| 322 |
+
View Documentation
|
| 323 |
+
</button>
|
| 324 |
+
</div>
|
| 325 |
+
</div>
|
| 326 |
+
</section>
|
| 327 |
+
|
| 328 |
+
<!-- Footer -->
|
| 329 |
+
<footer class="py-12 bg-dark border-t border-gray-800">
|
| 330 |
+
<div class="container mx-auto px-6">
|
| 331 |
+
<div class="grid grid-cols-1 md:grid-cols-4 gap-8">
|
| 332 |
+
<div>
|
| 333 |
+
<div class="flex items-center space-x-2 mb-4">
|
| 334 |
+
<div class="w-8 h-8 rounded-full bg-gradient-to-r from-primary to-accent flex items-center justify-center">
|
| 335 |
+
<i data-feather="code" class="text-white w-4 h-4"></i>
|
| 336 |
+
</div>
|
| 337 |
+
<span class="text-xl font-bold">Vibecode<span class="text-accent">Studio</span></span>
|
| 338 |
+
</div>
|
| 339 |
+
<p class="text-gray-400">
|
| 340 |
+
Creative coding platform for developers and designers.
|
| 341 |
+
</p>
|
| 342 |
+
</div>
|
| 343 |
+
<div>
|
| 344 |
+
<h4 class="text-lg font-semibold mb-4">Product</h4>
|
| 345 |
+
<ul class="space-y-2 text-gray-400">
|
| 346 |
+
<li><a href="index.html" class="hover:text-primary transition">Features</a></li>
|
| 347 |
+
<li><a href="#" class="hover:text-primary transition">API</a></li>
|
| 348 |
+
<li><a href="chat.html" class="hover:text-primary transition">Free Chat</a></li>
|
| 349 |
+
<li><a href="#" class="hover:text-primary transition">Documentation</a></li>
|
| 350 |
+
</ul>
|
| 351 |
+
</div>
|
| 352 |
+
<div>
|
| 353 |
+
<h4 class="text-lg font-semibold mb-4">Company</h4>
|
| 354 |
+
<ul class="space-y-2 text-gray-400">
|
| 355 |
+
<li><a href="#" class="hover:text-primary transition">About</a></li>
|
| 356 |
+
<li><a href="#" class="hover:text-primary transition">Blog</a></li>
|
| 357 |
+
<li><a href="#" class="hover:text-primary transition">Careers</a></li>
|
| 358 |
+
<li><a href="#" class="hover:text-primary transition">Contact</a></li>
|
| 359 |
+
</ul>
|
| 360 |
+
</div>
|
| 361 |
+
<div>
|
| 362 |
+
<h4 class="text-lg font-semibold mb-4">Connect</h4>
|
| 363 |
+
<div class="flex space-x-4">
|
| 364 |
+
<a href="#" class="text-gray-400 hover:text-primary transition">
|
| 365 |
+
<i data-feather="github"></i>
|
| 366 |
+
</a>
|
| 367 |
+
<a href="#" class="text-gray-400 hover:text-primary transition">
|
| 368 |
+
<i data-feather="twitter"></i>
|
| 369 |
+
</a>
|
| 370 |
+
<a href="#" class="text-gray-400 hover:text-primary transition">
|
| 371 |
+
<i data-feather="linkedin"></i>
|
| 372 |
+
</a>
|
| 373 |
+
<a href="#" class="text-gray-400 hover:text-primary transition">
|
| 374 |
+
<i data-feather="discord"></i>
|
| 375 |
+
</a>
|
| 376 |
+
</div>
|
| 377 |
+
</div>
|
| 378 |
+
</div>
|
| 379 |
+
<div class="border-t border-gray-800 mt-12 pt-8 text-center text-gray-500">
|
| 380 |
+
<p>© 2023 Vibecode Studio. All rights reserved.</p>
|
| 381 |
+
</div>
|
| 382 |
+
</div>
|
| 383 |
+
</footer>
|
| 384 |
+
|
| 385 |
+
<script>
|
| 386 |
+
// Initialize Feather Icons
|
| 387 |
+
feather.replace();
|
| 388 |
+
|
| 389 |
+
// Tab switching
|
| 390 |
+
document.getElementById('sdk-tab').addEventListener('click', function() {
|
| 391 |
+
this.classList.add('tab-active');
|
| 392 |
+
document.getElementById('fetch-tab').classList.remove('tab-active');
|
| 393 |
+
});
|
| 394 |
+
|
| 395 |
+
document.getElementById('fetch-tab').addEventListener('click', function() {
|
| 396 |
+
this.classList.add('tab-active');
|
| 397 |
+
document.getElementById('sdk-tab').classList.remove('tab-active');
|
| 398 |
+
});
|
| 399 |
+
|
| 400 |
+
// Mobile menu toggle
|
| 401 |
+
document.getElementById('menu-toggle').addEventListener('click', function() {
|
| 402 |
+
const menu = document.querySelector('.mobile-menu');
|
| 403 |
+
menu.classList.toggle('hidden');
|
| 404 |
+
});
|
| 405 |
+
</script>
|
| 406 |
+
</body>
|
| 407 |
+
</html>
|
|
@@ -71,10 +71,10 @@
|
|
| 71 |
<div class="hidden md:flex space-x-8">
|
| 72 |
<a href="index.html" class="hover:text-primary transition">Home</a>
|
| 73 |
<a href="#" class="hover:text-primary transition">Features</a>
|
| 74 |
-
<a href="
|
| 75 |
<a href="#" class="hover:text-primary transition">Pricing</a>
|
| 76 |
</div>
|
| 77 |
-
|
| 78 |
<button class="px-4 py-2 rounded-lg bg-primary hover:bg-primary/80 transition">Sign In</button>
|
| 79 |
<button id="menu-toggle" class="md:hidden text-light">
|
| 80 |
<i data-feather="menu"></i>
|
|
|
|
| 71 |
<div class="hidden md:flex space-x-8">
|
| 72 |
<a href="index.html" class="hover:text-primary transition">Home</a>
|
| 73 |
<a href="#" class="hover:text-primary transition">Features</a>
|
| 74 |
+
<a href="api.html" class="hover:text-primary transition">API</a>
|
| 75 |
<a href="#" class="hover:text-primary transition">Pricing</a>
|
| 76 |
</div>
|
| 77 |
+
<div class="flex items-center space-x-4">
|
| 78 |
<button class="px-4 py-2 rounded-lg bg-primary hover:bg-primary/80 transition">Sign In</button>
|
| 79 |
<button id="menu-toggle" class="md:hidden text-light">
|
| 80 |
<i data-feather="menu"></i>
|
|
@@ -70,10 +70,10 @@
|
|
| 70 |
<div class="hidden md:flex space-x-8">
|
| 71 |
<a href="#" class="hover:text-primary transition">Home</a>
|
| 72 |
<a href="#" class="hover:text-primary transition">Features</a>
|
| 73 |
-
<a href="
|
| 74 |
<a href="chat.html" class="hover:text-primary transition">Chat</a>
|
| 75 |
</div>
|
| 76 |
-
|
| 77 |
<button class="px-4 py-2 rounded-lg bg-primary hover:bg-primary/80 transition">Get Started</button>
|
| 78 |
<button id="menu-toggle" class="md:hidden text-light">
|
| 79 |
<i data-feather="menu"></i>
|
|
@@ -236,10 +236,10 @@
|
|
| 236 |
<span>Model selection and customization</span>
|
| 237 |
</li>
|
| 238 |
</ul>
|
| 239 |
-
<
|
| 240 |
View Documentation
|
| 241 |
-
</
|
| 242 |
-
|
| 243 |
</div>
|
| 244 |
</div>
|
| 245 |
</section>
|
|
@@ -283,11 +283,11 @@
|
|
| 283 |
<h4 class="text-lg font-semibold mb-4">Product</h4>
|
| 284 |
<ul class="space-y-2 text-gray-400">
|
| 285 |
<li><a href="#" class="hover:text-primary transition">Features</a></li>
|
| 286 |
-
<li><a href="
|
| 287 |
<li><a href="chat.html" class="hover:text-primary transition">Free Chat</a></li>
|
| 288 |
<li><a href="#" class="hover:text-primary transition">Documentation</a></li>
|
| 289 |
</ul>
|
| 290 |
-
|
| 291 |
<div>
|
| 292 |
<h4 class="text-lg font-semibold mb-4">Company</h4>
|
| 293 |
<ul class="space-y-2 text-gray-400">
|
|
|
|
| 70 |
<div class="hidden md:flex space-x-8">
|
| 71 |
<a href="#" class="hover:text-primary transition">Home</a>
|
| 72 |
<a href="#" class="hover:text-primary transition">Features</a>
|
| 73 |
+
<a href="api.html" class="hover:text-primary transition">API</a>
|
| 74 |
<a href="chat.html" class="hover:text-primary transition">Chat</a>
|
| 75 |
</div>
|
| 76 |
+
<div class="flex items-center space-x-4">
|
| 77 |
<button class="px-4 py-2 rounded-lg bg-primary hover:bg-primary/80 transition">Get Started</button>
|
| 78 |
<button id="menu-toggle" class="md:hidden text-light">
|
| 79 |
<i data-feather="menu"></i>
|
|
|
|
| 236 |
<span>Model selection and customization</span>
|
| 237 |
</li>
|
| 238 |
</ul>
|
| 239 |
+
<a href="api.html" class="px-6 py-3 rounded-lg bg-primary hover:bg-primary/80 transition font-medium inline-block">
|
| 240 |
View Documentation
|
| 241 |
+
</a>
|
| 242 |
+
</div>
|
| 243 |
</div>
|
| 244 |
</div>
|
| 245 |
</section>
|
|
|
|
| 283 |
<h4 class="text-lg font-semibold mb-4">Product</h4>
|
| 284 |
<ul class="space-y-2 text-gray-400">
|
| 285 |
<li><a href="#" class="hover:text-primary transition">Features</a></li>
|
| 286 |
+
<li><a href="api.html" class="hover:text-primary transition">API</a></li>
|
| 287 |
<li><a href="chat.html" class="hover:text-primary transition">Free Chat</a></li>
|
| 288 |
<li><a href="#" class="hover:text-primary transition">Documentation</a></li>
|
| 289 |
</ul>
|
| 290 |
+
</div>
|
| 291 |
<div>
|
| 292 |
<h4 class="text-lg font-semibold mb-4">Company</h4>
|
| 293 |
<ul class="space-y-2 text-gray-400">
|