Spaces:
Running
Running
Download index.html from Modelflare/api-recipes: direct link, hf CLI and curl.
- Browser
- Download file 12.6 kB
-
https://huggingface.co/spaces/Modelflare/api-recipes/resolve/main/index.html
- Command line
-
hf download hf://spaces/Modelflare/api-recipes/index.html
-
curl -L -o index.html https://huggingface.co/spaces/Modelflare/api-recipes/resolve/main/index.html
12.6 kB
| <html lang="en"> | |
| <head> | |
| <meta charset="UTF-8" /> | |
| <meta name="viewport" content="width=device-width, initial-scale=1" /> | |
| <title>API Recipes β Modelflare</title> | |
| <meta name="description" content="Copy-paste Modelflare API recipes: chat, streaming, models, Responses, Anthropic, images, video." /> | |
| <style> | |
| :root { | |
| --bg:#0b1020; --card:#121a2f; --text:#e8ecf7; --muted:#9aa6c2; | |
| --accent:#8b5cf6; --accent2:#ec4899; --border:rgba(255,255,255,.08); --ok:#34d399; --warn:#fbbf24; | |
| } | |
| *{box-sizing:border-box} | |
| body{ | |
| margin:0;font-family:ui-sans-serif,system-ui,-apple-system,Segoe UI,Roboto,Helvetica,Arial,sans-serif; | |
| background:radial-gradient(1200px 600px at 10% -10%,#2a1850 0%,transparent 50%), | |
| radial-gradient(900px 500px at 100% 0%,#3b0f2e 0%,transparent 45%),var(--bg); | |
| color:var(--text);min-height:100vh;line-height:1.55; | |
| } | |
| .wrap{max-width:880px;margin:0 auto;padding:40px 18px 64px} | |
| .lang{display:flex;gap:8px;margin-bottom:16px} | |
| .lang button{background:transparent;border:1px solid var(--border);color:var(--muted);border-radius:999px;padding:6px 12px;cursor:pointer} | |
| .lang button.on{color:#fff;border-color:rgba(139,92,246,.5);background:rgba(139,92,246,.2)} | |
| .badge{display:inline-flex;gap:8px;align-items:center;padding:6px 12px;border-radius:999px;background:rgba(139,92,246,.15);border:1px solid rgba(139,92,246,.35);color:#d6c7ff;font-size:13px;margin-bottom:18px} | |
| h1{font-size:clamp(28px,5vw,40px);line-height:1.15;margin:0 0 12px} | |
| .lead{color:var(--muted);font-size:17px;margin:0 0 24px;max-width:680px} | |
| .cta{display:flex;flex-wrap:wrap;gap:10px;margin-bottom:28px} | |
| a.btn{display:inline-flex;align-items:center;padding:12px 16px;border-radius:12px;text-decoration:none;font-weight:600} | |
| a.primary{background:linear-gradient(135deg,var(--accent),var(--accent2));color:#fff} | |
| a.ghost{border:1px solid var(--border);color:var(--text)} | |
| .grid{display:grid;grid-template-columns:repeat(auto-fit,minmax(220px,1fr));gap:14px;margin-bottom:28px} | |
| .card{background:var(--card);border:1px solid var(--border);border-radius:16px;padding:18px} | |
| .card h3{margin:0 0 8px;font-size:16px} | |
| .card p{margin:0;color:var(--muted);font-size:14px} | |
| h2{font-size:18px;margin:28px 0 10px} | |
| h3.sec{font-size:15px;margin:18px 0 8px;color:#d6c7ff} | |
| ol,ul{color:var(--muted);padding-left:1.2em} | |
| ol li,ul li{margin:6px 0} | |
| pre{background:#070b16;border:1px solid var(--border);border-radius:14px;padding:14px 16px;overflow:auto;font-size:12.5px;color:#d7def0;position:relative} | |
| .copy{position:absolute;top:8px;right:8px;font-size:11px;border:1px solid var(--border);background:#121a2f;color:var(--muted);border-radius:8px;padding:4px 8px;cursor:pointer} | |
| .foot{margin-top:24px;color:var(--muted);font-size:13px} | |
| .note{background:var(--card);border:1px solid var(--border);border-radius:14px;padding:14px 16px;color:var(--muted);font-size:14px;margin-top:16px} | |
| .note strong{color:var(--ok)} | |
| .tip{border-left:3px solid var(--warn);padding-left:12px;margin:12px 0;color:var(--muted);font-size:14px} | |
| table{width:100%;border-collapse:collapse;font-size:13px;margin:12px 0 20px} | |
| th,td{border:1px solid var(--border);padding:10px 12px;text-align:left;vertical-align:top} | |
| th{background:rgba(139,92,246,.12);color:#d6c7ff;font-weight:600} | |
| td{color:var(--muted)} | |
| code{font-family:ui-monospace,SFMono-Regular,Menlo,Consolas,monospace} | |
| .hidden{display:none} | |
| a{color:#c4b5fd} | |
| </style> | |
| </head> | |
| <body> | |
| <div class="wrap"> | |
| <section id="en"> | |
| <div class="badge">API Recipes</div> | |
| <h1>Modelflare API recipes (copy-paste)</h1> | |
| <p class="lead">Chat / streaming / list models / Responses / Anthropic / images / video. Auth: <code>Authorization: Bearer YOUR_MODELFLARE_API_KEY</code>. When fields vary by model, follow the linked docs pages.</p> | |
| <div class="cta"> | |
| <a class="btn primary" href="https://modelflare.dev/?utm_source=huggingface&utm_medium=space&utm_campaign=api_recipes" target="_blank" rel="noopener">Open Console β</a> | |
| <a class="btn ghost" href="https://docs.modelflare.dev/guides/endpoints/?utm_source=huggingface&utm_medium=space&utm_campaign=api_recipes" target="_blank" rel="noopener">Endpoint picker</a> | |
| <a class="btn ghost" href="https://huggingface.co/spaces/Modelflare/coding-agents" target="_blank" rel="noopener">Coding Agents</a> | |
| <a class="btn ghost" href="https://huggingface.co/spaces/Modelflare/openai-sdk" target="_blank" rel="noopener">OpenAI SDK</a> | |
| <a class="btn ghost" href="https://huggingface.co/spaces/Modelflare/blog" target="_blank" rel="noopener">Blog</a> | |
| <a class="btn ghost" href="https://huggingface.co/datasets/Modelflare/api-examples" target="_blank" rel="noopener">Examples dataset</a> | |
| </div> | |
| <div class="tip">Sample model IDs such as <code>gpt-5.6-sol</code> must be enabled on your keyβs group. Live catalog = console.</div> | |
| <h2>Endpoint picker</h2> | |
| <table> | |
| <thead><tr><th>Family</th><th>Entry</th><th>Use for</th></tr></thead> | |
| <tbody> | |
| <tr><td>Chat Completions</td><td><code>POST /v1/chat/completions</code></td><td>OpenAI-compatible chat</td></tr> | |
| <tr><td>Responses</td><td><code>POST /v1/responses</code></td><td>Codex, Grok Build</td></tr> | |
| <tr><td>Anthropic Messages</td><td><code>ANTHROPIC_BASE_URL=https://modelflare.dev</code></td><td>Claude Code (CLI appends path)</td></tr> | |
| <tr><td>Images</td><td><code>POST /v1/images/generations</code></td><td>GPT Images / Wan / Seedream</td></tr> | |
| <tr><td>Gemini native</td><td><code>POST /v1/models/{model}:generateContent</code></td><td>Gemini image models (Gemini CLI builds the same path under <code>/v1beta</code>, served only on <code>modelflare.dev</code>)</td></tr> | |
| <tr><td>Video</td><td><code>POST /v1/videos</code> β poll <code>GET /v1/videos/{task_id}</code> β <code>GET /v1/videos/{task_id}/content</code></td><td>Async video tasks</td></tr> | |
| <tr><td>Models</td><td><code>GET /v1/models</code></td><td>Models the current key can call</td></tr> | |
| </tbody> | |
| </table> | |
| <p class="foot">Full table: <a href="https://docs.modelflare.dev/guides/endpoints/?utm_source=huggingface&utm_medium=space&utm_campaign=api_recipes" target="_blank" rel="noopener">docs β endpoints</a></p> | |
| <h2>1) Chat Completions β curl</h2> | |
| <pre><button class="copy" type="button">Copy</button><code>curl https://modelflare.dev/v1/chat/completions \ | |
| -H "Authorization: Bearer YOUR_MODELFLARE_API_KEY" \ | |
| -H "Content-Type: application/json" \ | |
| -d '{"model":"gpt-5.6-sol","messages":[{"role":"user","content":"ping"}]}'</code></pre> | |
| <h2>2) Chat Completions β Python</h2> | |
| <pre><button class="copy" type="button">Copy</button><code>from openai import OpenAI | |
| client = OpenAI( | |
| api_key="YOUR_MODELFLARE_API_KEY", | |
| base_url="https://modelflare.dev/v1", | |
| ) | |
| r = client.chat.completions.create( | |
| model="gpt-5.6-sol", | |
| messages=[{"role": "user", "content": "Hello from Hugging Face"}], | |
| ) | |
| print(r.choices[0].message.content)</code></pre> | |
| <h2>3) Streaming chat</h2> | |
| <p class="tip">The docs do not include a streaming example; this follows the OpenAI SDK <code>stream=True</code> pattern. Once content has been sent, the gateway does not replay a stream on another route.</p> | |
| <pre><button class="copy" type="button">Copy</button><code>stream = client.chat.completions.create( | |
| model="gpt-5.6-sol", | |
| messages=[{"role": "user", "content": "Say hi in one line"}], | |
| stream=True, | |
| ) | |
| for chunk in stream: | |
| print(chunk.choices[0].delta.content or "", end="", flush=True)</code></pre> | |
| <h2>4) List models</h2> | |
| <pre><button class="copy" type="button">Copy</button><code>curl https://modelflare.dev/v1/models \ | |
| -H "Authorization: Bearer YOUR_MODELFLARE_API_KEY"</code></pre> | |
| <h2>5) Responses API (for Codex) β curl stub</h2> | |
| <p class="tip">For full Codex install and <code>wire_api=responses</code>, follow the docs. This is a minimal request sketch only.</p> | |
| <pre><button class="copy" type="button">Copy</button><code>curl https://modelflare.dev/v1/responses \ | |
| -H "Authorization: Bearer YOUR_MODELFLARE_API_KEY" \ | |
| -H "Content-Type: application/json" \ | |
| -d '{"model":"gpt-5.6-sol","input":"Reply with one sentence confirming the model."}'</code></pre> | |
| <p class="foot"><a href="https://docs.modelflare.dev/guides/clients/codex/?utm_source=huggingface&utm_medium=space&utm_campaign=api_recipes" target="_blank" rel="noopener">Full Codex guide β</a></p> | |
| <h2>6) Anthropic Messages</h2> | |
| <p class="tip">The docs document Anthropic Messages through Claude Code: set <code>ANTHROPIC_BASE_URL=https://modelflare.dev</code> (no <code>/v1</code>); the CLI appends the Messages path itself. Raw HTTP headers are not documented, so no curl sketch is shown.</p> | |
| <p class="foot"><a href="https://docs.modelflare.dev/guides/clients/claude-code/?utm_source=huggingface&utm_medium=space&utm_campaign=api_recipes" target="_blank" rel="noopener">Full Claude Code guide β</a></p> | |
| <h2>7) Images</h2> | |
| <p class="tip">Documented <code>gpt-image-2</code> example. Fields vary by model; use a Smart API Key or a <code>media</code> group key.</p> | |
| <pre><button class="copy" type="button">Copy</button><code>curl https://modelflare.dev/v1/images/generations \ | |
| -H "Authorization: Bearer YOUR_MODELFLARE_API_KEY" \ | |
| -H "Content-Type: application/json" \ | |
| -d '{ | |
| "model": "gpt-image-2", | |
| "prompt": "A white cat runs through a neon-lit street in the rain", | |
| "size": "1024x1024", "n": 1 | |
| }'</code></pre> | |
| <p class="foot"><a href="https://docs.modelflare.dev/models/image/?utm_source=huggingface&utm_medium=space&utm_campaign=api_recipes" target="_blank" rel="noopener">Image models docs β</a></p> | |
| <h2>8) Video: create, poll, download</h2> | |
| <ol> | |
| <li><code>POST /v1/videos</code> creates an async task and returns <code>id</code> (compatibility responses may use <code>task_id</code>). The body is family-specific; this is the documented Seedance example.</li> | |
| <li>Poll <code>GET /v1/videos/{task_id}</code> while <code>status</code> is <code>queued</code> or <code>in_progress</code>; stop at <code>completed</code> or <code>failed</code>.</li> | |
| <li>Download <code>GET /v1/videos/{task_id}/content</code>; result URLs can expire, so store the file promptly.</li> | |
| </ol> | |
| <pre><button class="copy" type="button">Copy</button><code>curl https://modelflare.dev/v1/videos \ | |
| -H "Authorization: Bearer YOUR_MODELFLARE_API_KEY" \ | |
| -H "Content-Type: application/json" \ | |
| -d '{ | |
| "model": "seedance-2.5", | |
| "content": [{"type": "text", "text": "A cat walks through a sunlit room"}], | |
| "resolution": "720p", | |
| "duration": 5, | |
| "ratio": "16:9" | |
| }' | |
| curl https://modelflare.dev/v1/videos/TASK_ID \ | |
| -H "Authorization: Bearer YOUR_MODELFLARE_API_KEY" | |
| curl --fail --location \ | |
| https://modelflare.dev/v1/videos/TASK_ID/content \ | |
| -H "Authorization: Bearer YOUR_MODELFLARE_API_KEY" \ | |
| --output seedance-result.mp4</code></pre> | |
| <p class="foot"><a href="https://docs.modelflare.dev/models/video/?utm_source=huggingface&utm_medium=space&utm_campaign=api_recipes" target="_blank" rel="noopener">Video models docs β</a></p> | |
| <div class="note"> | |
| <strong>Coming from Hub?</strong> | |
| <a href="https://huggingface.co/spaces/Modelflare/start">start</a> Β· | |
| <a href="https://huggingface.co/spaces/Modelflare/coding-agents">coding-agents</a> Β· | |
| <a href="https://huggingface.co/collections/Modelflare/modelflare-getting-started">Getting Started</a>. | |
| Gradio Chat needs HF PRO (upcoming); use console + API for now. | |
| </div> | |
| </section> | |
| </div> | |
| <script> | |
| document.querySelectorAll('pre .copy').forEach(btn=>{ | |
| btn.addEventListener('click',async()=>{ | |
| const code=btn.parentElement.querySelector('code').innerText; | |
| try{await navigator.clipboard.writeText(code);const t=btn.textContent;btn.textContent='Copied';setTimeout(()=>btn.textContent=t,1200)}catch(_){} | |
| }); | |
| }); | |
| </script> | |
| </body> | |
| </html> | |