Download index.html from huggingface/inference-providers-setup: direct link, hf CLI and curl.
- Browser
- Download file 61.5 kB
-
https://huggingface.co/spaces/huggingface/inference-providers-setup/resolve/main/index.html
- Command line
-
hf download hf://spaces/huggingface/inference-providers-setup/index.html
-
curl -L -o index.html https://huggingface.co/spaces/huggingface/inference-providers-setup/resolve/main/index.html
61.5 kB
| <html lang="en"> | |
| <head> | |
| <meta charset="utf-8" /> | |
| <meta name="viewport" content="width=device-width, initial-scale=1" /> | |
| <title>Inference Providers setup</title> | |
| <link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/@fontsource/source-sans-pro@5.3.0/400.css" /> | |
| <link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/@fontsource/source-sans-pro@5.3.0/600.css" /> | |
| <link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/@fontsource/source-sans-pro@5.3.0/700.css" /> | |
| <link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/@fontsource/geist-mono@5.3.0/400.css" /> | |
| <link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/@fontsource/geist-mono@5.3.0/600.css" /> | |
| <link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/highlight.js/11.9.0/styles/atom-one-light.min.css" /> | |
| <script src="https://cdnjs.cloudflare.com/ajax/libs/highlight.js/11.9.0/highlight.min.js"></script> | |
| <style> | |
| :root { | |
| --bg: #ffffff; --fg: #111827; --muted: #6b7280; --soft: #f9fafb; --line: #e5e7eb; --line-strong: #d1d5db; | |
| --link: #2563eb; --accent: #ffd21e; --code-bg: #f8fafc; --code-fg: #1f2937; --inline-code: #f3f4f6; | |
| --sans: "Source Sans Pro", ui-sans-serif, system-ui, sans-serif; --mono: "Geist Mono", ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, "Liberation Mono", "Courier New", monospace; | |
| } | |
| .dark { | |
| --bg: #0b0f19; --fg: #e5e7eb; --muted: #9ca3af; --soft: #111827; --line: #1f2937; --line-strong: #374151; | |
| --link: #60a5fa; --code-bg: #0f172a; --code-fg: #e2e8f0; --inline-code: #1f2937; | |
| } | |
| * { box-sizing: border-box; } | |
| html { scroll-padding-top: 72px; } | |
| body { margin: 0; background: var(--bg); color: var(--fg); font-family: var(--sans); font-size: 16px; line-height: 1.65; } | |
| a { color: var(--link); text-decoration: none; } | |
| a:hover { text-decoration: underline; } | |
| button { font-family: inherit; color: inherit; } | |
| /* top bar */ | |
| .topbar { position: sticky; top: 0; z-index: 20; display: flex; align-items: center; gap: 12px; height: 56px; padding: 0 18px; background: color-mix(in srgb, var(--bg) 92%, transparent); backdrop-filter: blur(8px); border-bottom: 1px solid var(--line); } | |
| .brand { display: flex; align-items: center; gap: 8px; color: var(--fg); font-weight: 700; font-size: 17px; } | |
| .brand:hover { text-decoration: none; } | |
| .logo { font-size: 24px; } | |
| .crumb { color: var(--muted); } | |
| .crumb .sep { margin: 0 4px; } | |
| .proto-pill { font-size: 11px; font-weight: 700; text-transform: uppercase; letter-spacing: .04em; background: var(--accent); color: #000; padding: 1px 8px; border-radius: 999px; } | |
| .search { margin-left: auto; display: flex; align-items: center; gap: 24px; min-width: 260px; border: 1px solid var(--line); background: var(--soft); border-radius: 8px; padding: 6px 10px; color: var(--muted); cursor: pointer; font-size: 14px; } | |
| .search kbd { margin-left: auto; font-family: var(--mono); font-size: 11px; border: 1px solid var(--line-strong); border-radius: 4px; padding: 0 5px; } | |
| .icon-btn { border: 0; background: none; font-size: 18px; cursor: pointer; color: var(--muted); padding: 4px 6px; } | |
| #menu-toggle { display: none; } | |
| /* layout */ | |
| .layout { display: grid; grid-template-columns: 270px minmax(0, 1fr) 230px; max-width: 1440px; margin: 0 auto; } | |
| .sidebar { position: sticky; top: 56px; height: calc(100vh - 56px); overflow-y: auto; border-right: 1px solid var(--line); padding: 16px 12px 60px 18px; font-size: 14.5px; } | |
| .sidebar-head { padding: 4px 8px 12px; border-bottom: 1px solid var(--line); margin-bottom: 8px; } | |
| .sidebar-head .lib { font-weight: 700; font-size: 16px; } | |
| .sidebar-head .version { font-size: 12px; color: var(--muted); } | |
| .nav-group > summary { list-style: none; cursor: pointer; padding: 6px 8px; font-weight: 700; font-size: 12.5px; text-transform: uppercase; letter-spacing: .05em; color: var(--muted); } | |
| .nav-group > summary::-webkit-details-marker { display: none; } | |
| .nav-group > summary::before { content: "▸"; display: inline-block; width: 14px; transition: transform .15s; } | |
| .nav-group[open] > summary::before { transform: rotate(90deg); } | |
| .nav-group.depth-1 > summary, .nav-group.depth-2 > summary { text-transform: none; letter-spacing: 0; font-size: 14.5px; font-weight: 600; color: var(--fg); } | |
| .nav-children { margin-left: 8px; padding-left: 6px; border-left: 1px solid var(--line); } | |
| .depth-0 > .nav-children { border-left: 0; margin-left: 0; } | |
| .nav-link { display: flex; align-items: center; gap: 6px; padding: 4px 8px; border-radius: 6px; color: var(--fg); } | |
| .nav-link:hover { background: var(--soft); text-decoration: none; } | |
| .nav-link.active { background: color-mix(in srgb, var(--accent) 32%, transparent); font-weight: 600; } | |
| .badge { font-size: 10px; font-weight: 700; padding: 0 6px; border-radius: 999px; line-height: 16px; } | |
| .badge-new { background: var(--accent); color: #000; } | |
| .badge-changed { background: #dbeafe; color: #1e40af; } | |
| .dark .badge-changed { background: #1e3a8a; color: #dbeafe; } | |
| main { position: relative; min-width: 0; padding: 28px 52px 80px; } | |
| .toc { position: sticky; top: 56px; height: calc(100vh - 56px); overflow-y: auto; padding: 32px 16px; font-size: 13.5px; } | |
| .toc.empty { visibility: hidden; } | |
| .toc-title { font-size: 12px; font-weight: 700; text-transform: uppercase; letter-spacing: .05em; color: var(--muted); margin-bottom: 8px; } | |
| .toc a { display: block; color: var(--muted); padding: 3px 0; line-height: 1.35; } | |
| .toc a.toc-h3 { padding-left: 12px; } | |
| .toc a:hover { color: var(--fg); text-decoration: none; } | |
| /* copy menu */ | |
| .copy-menu-wrap { position: absolute; right: 52px; top: 30px; z-index: 5; } | |
| .copy-group { display: flex; border: 1px solid var(--line); border-radius: 8px; overflow: hidden; background: var(--bg); } | |
| .copy-group button { border: 0; background: none; padding: 5px 10px; font-size: 13.5px; cursor: pointer; } | |
| .copy-group button:hover { background: var(--soft); } | |
| .copy-more { border-left: 1px solid var(--line) ; } | |
| .copy-menu { display: none; position: absolute; right: 0; top: 38px; width: 280px; background: var(--bg); border: 1px solid var(--line); border-radius: 10px; box-shadow: 0 12px 32px rgba(0,0,0,.14); padding: 6px; } | |
| .copy-menu.open { display: block; } | |
| .copy-menu button { display: block; width: 100%; text-align: left; border: 0; background: none; border-radius: 6px; padding: 7px 10px; cursor: pointer; } | |
| .copy-menu button:hover { background: var(--soft); } | |
| .copy-menu b { display: block; font-size: 14px; } | |
| .copy-menu small { color: var(--muted); font-size: 12.5px; } | |
| /* doc content */ | |
| /* Tailwind's preflight is off, but its border classes rely on this */ | |
| .doc *, .doc *::before, .doc *::after { border-width: 0; border-style: solid; border-color: var(--line); } | |
| .doc { max-width: 820px; } | |
| .doc h1, .doc h2, .doc h3, .doc h4 { font-weight: 700; } | |
| .doc h1 { font-size: 34px; line-height: 1.2; margin: 0 180px 18px 0; letter-spacing: -.01em; } | |
| .doc h2 { font-size: 24px; margin: 42px 0 12px; padding-top: 6px; letter-spacing: -.005em; } | |
| .doc h3 { font-size: 19px; margin: 28px 0 8px; } | |
| .doc h4 { font-size: 16px; margin: 22px 0 6px; } | |
| .doc .heading { position: relative; } | |
| .doc .anchor { position: absolute; left: -22px; color: var(--muted); opacity: 0; font-weight: 400; } | |
| .doc .heading:hover .anchor { opacity: 1; text-decoration: none; } | |
| .doc p, .doc ul, .doc ol { margin: 10px 0; } | |
| .doc ul, .doc ol { padding-left: 24px; } | |
| .doc li { margin: 3px 0; } | |
| .doc ul { list-style: disc; } .doc ol { list-style: decimal; } | |
| :where(.doc) img { max-width: 100%; } | |
| .doc hr { border: 0; border-top: 1px solid var(--line); margin: 28px 0; } | |
| .doc :not(pre) > code { font-family: var(--mono); font-size: .875em; background: var(--inline-code); padding: 1px 5px; border-radius: 5px; } | |
| .doc blockquote { margin: 14px 0; padding: 2px 16px; border-left: 3px solid var(--line-strong); color: var(--muted); } | |
| .doc details { border: 1px solid var(--line); border-radius: 8px; padding: 8px 12px; margin: 12px 0; } | |
| .doc summary { cursor: pointer; font-weight: 600; } | |
| .doc a.no-underline:hover, .doc a[class*="no-underline"]:hover { text-decoration: none; } | |
| .table-wrap { overflow-x: auto; margin: 14px 0; border: 1px solid var(--line); border-radius: 10px; } | |
| .doc table { width: 100%; border-collapse: collapse; font-size: 14.5px; } | |
| .doc th, .doc td { padding: 8px 12px; border-bottom: 1px solid var(--line); text-align: left; vertical-align: top; } | |
| .doc th { background: var(--soft); font-weight: 600; } | |
| .doc tbody tr:last-child td { border-bottom: 0; } | |
| .code-block { position: relative; margin: 14px 0; } | |
| .code-block pre { margin: 0; background: var(--code-bg); color: var(--code-fg); border: 1px solid var(--line); border-radius: 10px; padding: 14px 16px; overflow-x: auto; font-family: var(--mono); font-size: 14px; line-height: 1.71; } | |
| .copy-code { position: absolute; top: 8px; right: 8px; border: 1px solid var(--line); background: var(--bg); border-radius: 6px; font-size: 12px; padding: 2px 8px; cursor: pointer; opacity: 0; transition: opacity .15s; } | |
| .code-block:hover .copy-code { opacity: 1; } | |
| /* Without a CSS reset, the browser gives <code> its own generic monospace font */ | |
| pre code { font: inherit; } | |
| pre.mermaid { background: var(--soft); border: 1px solid var(--line); border-radius: 10px; padding: 16px; text-align: center; } | |
| /* hljs: atom-one-light (linked in dev.html) in light mode, the Hub's Night Owl palette in dark mode */ | |
| .hljs { background: transparent ; padding: 0 ; } | |
| .dark .hljs { color: #d6deeb; } | |
| .dark .hljs-keyword { color: #c792ea; font-style: italic; } | |
| .dark .hljs-built_in { color: #addb67; font-style: italic; } | |
| .dark .hljs-type, .dark .hljs-symbol, .dark .hljs-function, .dark .hljs-meta { color: #82aaff; } | |
| .dark .hljs-literal { color: #ff5874; } | |
| .dark .hljs-number { color: #f78c6c; } | |
| .dark .hljs-regexp { color: #5ca7e4; } | |
| .dark .hljs-string, .dark .hljs-meta-string { color: #ecc48d; } | |
| .dark .hljs-subst { color: #d3423e; } | |
| .dark .hljs-class { color: #ffcb8b; } | |
| .dark .hljs-title { color: #dcdcaa; font-style: italic; } | |
| .dark .hljs-title.function_, .dark .hljs-title.class_ { color: #82aaff; } | |
| .dark .hljs-params, .dark .hljs-doctag, .dark .hljs-tag, .dark .hljs-name, .dark .hljs-attr { color: #7fdbca; } | |
| .dark .hljs-comment { color: #637777; font-style: italic; } | |
| .dark .hljs-section { color: #82b1ff; } | |
| .dark .hljs-attribute { color: #80cbc4; } | |
| .dark .hljs-variable, .dark .hljs-property { color: #addb67; } | |
| .dark .hljs-link { color: #ff869a; } | |
| /* alerts (> [!TIP]) */ | |
| .alert { margin: 16px 0; padding: 10px 16px; border-radius: 10px; border: 1px solid; } | |
| .alert p { margin: 4px 0; } | |
| .alert-title { font-weight: 700; font-size: 14px; } | |
| .alert-tip { background: #f0fdf4; border-color: #bbf7d0; } .alert-tip .alert-title { color: #15803d; } | |
| .alert-note { background: #eff6ff; border-color: #bfdbfe; } .alert-note .alert-title { color: #1d4ed8; } | |
| .alert-warning { background: #fffbeb; border-color: #fde68a; } .alert-warning .alert-title { color: #b45309; } | |
| .dark .alert-tip { background: #052e16; border-color: #14532d; } .dark .alert-tip .alert-title { color: #86efac; } | |
| .dark .alert-note { background: #172554; border-color: #1e3a8a; } .dark .alert-note .alert-title { color: #93c5fd; } | |
| .dark .alert-warning { background: #2a1d05; border-color: #713f12; } .dark .alert-warning .alert-title { color: #fcd34d; } | |
| /* <hfoptions> */ | |
| .hfoptions { margin: 16px 0; } | |
| .hfoption-tabs { display: flex; flex-wrap: wrap; gap: 4px; border-bottom: 1px solid var(--line); margin-bottom: 4px; } | |
| .hfoption-tab { border: 0; background: none; padding: 7px 12px; font-size: 14px; color: var(--muted); cursor: pointer; border-bottom: 2px solid transparent; margin-bottom: -1px; } | |
| .hfoption-tab:hover { color: var(--fg); } | |
| .hfoption-tab.on { color: var(--fg); font-weight: 600; border-bottom-color: var(--fg); } | |
| .hfoption-panel { display: none; } | |
| .hfoption-panel.on { display: block; } | |
| /* <InferenceSnippet> */ | |
| .inference-snippet { border: 1px solid var(--line); border-radius: 10px; margin: 16px 0; padding: 10px 12px 8px; } | |
| .snippet-bar { display: flex; flex-wrap: wrap; align-items: center; gap: 12px; justify-content: space-between; } | |
| .snippet-bar select { margin-left: 6px; border: 1px solid var(--line); background: var(--bg); color: var(--fg); border-radius: 6px; padding: 3px 6px; font-family: inherit; } | |
| .snippet-clients button { border: 1px solid var(--line); background: var(--bg); border-radius: 6px; padding: 3px 10px; font-size: 13px; cursor: pointer; } | |
| .snippet-clients button.on { background: var(--fg); color: var(--bg); border-color: var(--fg); } | |
| .snippet-note { font-size: 12px; color: var(--muted); } | |
| /* footer */ | |
| #page-footer { max-width: 820px; margin-top: 56px; border-top: 1px solid var(--line); padding-top: 18px; } | |
| #page-footer .edit { font-size: 13.5px; color: var(--muted); margin-bottom: 16px; } | |
| .prevnext { display: flex; justify-content: space-between; gap: 12px; } | |
| .prevnext a { border: 1px solid var(--line); border-radius: 10px; padding: 10px 14px; color: var(--fg); min-width: 200px; } | |
| .prevnext a:hover { border-color: var(--line-strong); text-decoration: none; } | |
| .prevnext a.next { text-align: right; } | |
| .prevnext small { display: block; color: var(--muted); font-size: 12px; } | |
| /* dialogs */ | |
| .dialog { border: 1px solid var(--line); border-radius: 14px; padding: 0; width: min(620px, 92vw); background: var(--bg); color: var(--fg); box-shadow: 0 20px 50px rgba(0,0,0,.25); } | |
| .dialog::backdrop { background: rgba(0,0,0,.35); } | |
| #search-input { width: 100%; border: 0; border-bottom: 1px solid var(--line); padding: 14px 16px; font-size: 16px; font-family: inherit; background: transparent; color: var(--fg); outline: none; } | |
| #search-results { max-height: 60vh; overflow-y: auto; padding: 6px; } | |
| #search-results a { display: block; padding: 8px 10px; border-radius: 8px; color: var(--fg); } | |
| #search-results a:hover { background: var(--soft); text-decoration: none; } | |
| #search-results small { display: block; color: var(--muted); } | |
| #search-results .empty { padding: 14px; color: var(--muted); } | |
| #mcp-dialog { padding: 18px 20px; } | |
| #mcp-dialog h3 { margin: 0 0 6px; } | |
| .mcp-row { display: flex; gap: 8px; align-items: center; border: 1px solid var(--line); border-radius: 8px; padding: 6px 6px 6px 12px; } | |
| .mcp-row code { flex: 1; font-family: var(--mono); font-size: 13.5px; } | |
| .mcp-row button { border: 1px solid var(--line); background: var(--soft); border-radius: 6px; padding: 3px 10px; cursor: pointer; } | |
| #toast { position: fixed; bottom: 18px; left: 50%; transform: translateX(-50%) translateY(20px); background: #111827; color: #fff; padding: 8px 14px; border-radius: 8px; font-size: 14px; opacity: 0; pointer-events: none; transition: all .2s; z-index: 50; } | |
| #toast.on { opacity: 1; transform: translateX(-50%); } | |
| @media (max-width: 1180px) { .layout { grid-template-columns: 250px minmax(0, 1fr); } .toc { display: none; } } | |
| @media (max-width: 820px) { | |
| .layout { grid-template-columns: 1fr; } | |
| #menu-toggle { display: block; } | |
| .crumb, .proto-pill, .search span { display: none; } | |
| .search { min-width: 0; } | |
| .sidebar { display: none; position: fixed; top: 56px; left: 0; width: 290px; background: var(--bg); z-index: 15; box-shadow: 0 10px 30px rgba(0,0,0,.2); } | |
| .nav-open .sidebar { display: block; } | |
| main { padding: 20px; } | |
| .copy-menu-wrap { position: static; display: flex; justify-content: flex-end; margin-bottom: 8px; } | |
| .doc h1 { margin-right: 0; } | |
| } | |
| /* <QuickstartSnippet /> */ | |
| .qs { position: relative; margin: 26px 0 34px; } | |
| .qs-glow { display: none; } | |
| .doc .qs-card { position: relative; border: 1px solid var(--line); border-radius: 16px; background: var(--bg); padding: 8px; box-shadow: 0 1px 2px rgba(0,0,0,.04), 0 12px 32px -20px rgba(0,0,0,.18); } | |
| .qs button { font-family: inherit; cursor: pointer; } | |
| .qs-body { display: grid; grid-template-columns: 150px minmax(0, 1fr); gap: 8px; } | |
| .qs-surfaces { display: flex; flex-direction: column; gap: 2px; padding: 2px; } | |
| .qs-rail-label { padding: 12px 10px 4px; font-size: 11.5px; font-weight: 700; text-transform: uppercase; letter-spacing: .05em; color: var(--muted); } | |
| .qs-surfaces button, .qs-formats button { border: 0; background: none; color: var(--muted); padding: 6px 12px; border-radius: 9px; font-size: 14.5px; white-space: nowrap; } | |
| .qs-surfaces button { display: flex; align-items: center; gap: 9px; padding: 6px 8px; text-align: left; } | |
| .qs-surfaces button:hover, .qs-formats button:hover { color: var(--fg); background: var(--soft); } | |
| .qs-surfaces button.on { color: var(--fg); font-weight: 600; background: var(--soft); box-shadow: inset 0 0 0 1px var(--line); } | |
| .qs-logo { display: grid; place-items: center; width: 22px; height: 22px; flex: none; color: var(--fg); } | |
| .qs-logo svg { width: 20px; height: 20px; border-radius: 4px; } | |
| .qs-surfaces button:not(.on) .qs-logo { opacity: .75; } | |
| .doc .qs-panel { border: 1px solid var(--line); border-radius: 12px; overflow: hidden; } | |
| @media (max-width: 720px) { | |
| .qs-body { grid-template-columns: 1fr; } | |
| .qs-surfaces { flex-direction: row; overflow-x: auto; } | |
| .qs-rail-label { display: none; } | |
| } | |
| .doc .qs-subbar { display: flex; align-items: center; justify-content: space-between; gap: 8px; padding: 6px; border-bottom: 1px solid var(--line); background: var(--soft); overflow-x: auto; } | |
| .qs-subbar[hidden], .qs-install[hidden] { display: none ; } | |
| .qs-formats { display: flex; gap: 2px; } | |
| .qs-formats button { font-size: 13.5px; padding: 5px 10px; } | |
| .qs-formats button.on { color: var(--fg); font-weight: 600; background: var(--bg); box-shadow: 0 0 0 1px var(--line), 0 1px 2px rgba(0,0,0,.05); } | |
| .doc .qs-langs { display: flex; border: 1px solid var(--line); border-radius: 8px; overflow: hidden; background: var(--bg); flex-shrink: 0; } | |
| .qs-langs button { border: 0; background: none; color: var(--muted); padding: 4px 10px; font-size: 13px; } | |
| .qs-langs button.on { background: var(--fg); color: var(--bg); font-weight: 600; } | |
| .qs-langs button:disabled { opacity: .35; cursor: not-allowed; } | |
| .doc .qs-install { padding: 7px 16px; border-bottom: 1px dashed var(--line); background: var(--code-bg); } | |
| .doc .qs-install code { background: none; padding: 0; color: var(--muted); font-size: 12.5px; } | |
| .qs-code { position: relative; display: grid; grid-template-columns: auto 1fr; background: var(--code-bg); min-height: 300px; } | |
| .qs-gutter { padding: 16px 0 16px 16px; text-align: right; white-space: pre; font-family: var(--mono); font-size: 13px; line-height: 1.71; color: var(--line-strong); user-select: none; } | |
| .dark .qs-gutter { color: #4b5563; } | |
| .qs-code pre { margin: 0; padding: 16px 18px; overflow-x: auto; font-family: var(--mono); font-size: 13px; line-height: 1.71; color: var(--code-fg); } | |
| .doc .qs-copy { position: absolute; top: 10px; right: 10px; border: 1px solid var(--line); background: var(--bg); color: var(--muted); border-radius: 7px; padding: 3px 9px; font-size: 12px; z-index: 1; } | |
| .qs-copy:hover { color: var(--fg); } | |
| .qs-code[hidden], .qs-steps[hidden] { display: none ; } | |
| .doc .qs-steps { list-style: none; margin: 0; padding: 18px 18px 2px; max-height: 430px; overflow-y: auto; } | |
| .doc .qs-steps li { position: relative; display: grid; grid-template-columns: 26px 1fr; gap: 14px; margin: 0; padding: 0 0 18px; } | |
| .doc .qs-steps li:not(:last-child)::before { content: ""; position: absolute; left: 12.5px; top: 30px; bottom: 4px; border-left: 1px solid var(--line); } | |
| .doc .qs-num { display: grid; place-items: center; width: 26px; height: 26px; border: 1px solid var(--line-strong); border-radius: 999px; font-size: 13px; color: var(--muted); background: var(--bg); } | |
| .qs-step { min-width: 0; } | |
| .qs-step > b { display: block; font-size: 15px; line-height: 26px; } | |
| .doc .qs-step p { margin: 0; font-size: 14px; line-height: 1.5; color: var(--muted); } | |
| .qs-step p b { font-weight: 600; color: var(--fg); } | |
| .doc .qs-token { display: block; margin-top: 8px; border: 1px solid var(--line-strong); border-radius: 999px; padding: 6px; text-align: center; font-size: 14px; font-weight: 600; color: var(--fg); } | |
| .qs-token:hover { background: var(--soft); text-decoration: none; } | |
| .doc .qs-snippet { position: relative; margin-top: 8px; border: 1px solid var(--line); border-radius: 10px; background: var(--code-bg); } | |
| .qs-snippet pre { margin: 0; padding: 9px 14px; overflow-x: auto; font-family: var(--mono); font-size: 13.5px; line-height: 1.65; color: var(--code-fg); } | |
| .doc .qs-snippet .qs-copy { top: 7px; right: 7px; padding: 2px 8px; opacity: 0; transition: opacity .15s; } | |
| .qs-snippet:hover .qs-copy { opacity: 1; } | |
| .doc .qs-footer { display: flex; align-items: center; justify-content: space-between; gap: 10px; padding: 8px 10px 8px 8px; border-top: 1px solid var(--line); } | |
| .doc .qs-agent { display: inline-flex; align-items: center; gap: 7px; border: 1px solid var(--line); background: var(--bg); color: var(--fg); border-radius: 9px; padding: 6px 12px; font-size: 14px; font-weight: 600; } | |
| .qs-agent:hover { background: color-mix(in srgb, var(--accent) 22%, var(--bg)); } | |
| .qs-links { display: flex; gap: 16px; font-size: 14px; } | |
| .qs-links a { color: var(--muted); } | |
| .qs-links a:hover { color: var(--fg); text-decoration: none; } | |
| .qs-models { display: flex; flex-wrap: wrap; gap: 8px; padding: 12px 4px 4px; } | |
| .doc .qs-models button { display: inline-flex; align-items: center; gap: 7px; border: 1px solid var(--line); background: var(--bg); color: var(--fg); border-radius: 999px; padding: 3px 12px 3px 4px; font-size: 13.5px; } | |
| .qs-models button:hover { border-color: var(--line-strong); } | |
| .doc .qs-models button.on { border-color: var(--fg); box-shadow: 0 0 0 3px color-mix(in srgb, var(--accent) 45%, transparent); font-weight: 600; } | |
| .qs-models img { width: 22px; height: 22px; border-radius: 999px; margin: 0; background: #fff; } | |
| .qs-more { display: inline-flex; align-items: center; padding: 3px 10px; font-size: 13.5px; color: var(--muted); } | |
| .qs-stats { display: flex; flex-wrap: wrap; align-items: center; gap: 4px 14px; padding: 8px 8px 4px; font-size: 13px; color: var(--muted); min-height: 30px; } | |
| .qs-stats b { color: var(--fg); font-weight: 600; } | |
| .qs-live { margin-left: auto; color: #16a34a; font-size: 12px; } | |
| /* <PricingSnippet /> */ | |
| .px { display: grid; grid-template-columns: minmax(220px, 0.8fr) 1.4fr; gap: 28px; align-items: center; margin: 22px 0 30px; } | |
| .doc .px { border: 1px solid var(--line); border-radius: 16px; padding: 22px; background: var(--bg); } | |
| .px-zero { font-size: 96px; line-height: .9; font-weight: 700; letter-spacing: -.04em; color: var(--fg); } | |
| .px-zero span { color: #f59e0b; } | |
| .px-zero span { font-size: 64px; } | |
| .px-title { font-size: 24px; font-weight: 700; margin-top: 10px; } | |
| .doc .px-sub { color: var(--muted); margin: 6px 0 12px; } | |
| .doc .px-points { list-style: none; padding: 0; margin: 0 0 12px; font-size: 14.5px; } | |
| .doc .px-points li { position: relative; padding-left: 20px; margin: 4px 0; } | |
| .px-points li::before { content: "✓"; position: absolute; left: 0; color: #f59e0b; font-weight: 700; } | |
| .px-link { font-weight: 600; font-size: 14.5px; } | |
| .doc .px-card { border: 1px solid var(--line); border-radius: 12px; background: var(--bg); padding: 12px; } | |
| .px button { font-family: inherit; cursor: pointer; } | |
| .px-models { display: flex; flex-wrap: wrap; gap: 6px; } | |
| .doc .px-models button { display: inline-flex; align-items: center; gap: 6px; border: 1px solid var(--line); background: var(--bg); color: var(--fg); border-radius: 999px; padding: 2px 10px 2px 3px; font-size: 12.5px; } | |
| .doc .px-models button.on { border-color: var(--fg); font-weight: 600; box-shadow: 0 0 0 3px color-mix(in srgb, var(--accent) 45%, transparent); } | |
| .px-models img { width: 18px; height: 18px; border-radius: 999px; margin: 0; background: #fff; } | |
| .doc .px-profiles { display: grid; grid-template-columns: repeat(3, 1fr); gap: 4px; margin-top: 10px; padding: 3px; border: 1px solid var(--line); border-radius: 10px; background: var(--soft); } | |
| .px-profiles button { border: 0; background: none; color: var(--muted); border-radius: 8px; padding: 5px 6px; text-align: center; } | |
| .px-profiles button b { display: block; font-size: 13px; } | |
| .px-profiles button small { font-size: 11.5px; } | |
| .px-profiles button.on { background: var(--bg); color: var(--fg); box-shadow: 0 0 0 1px var(--line), 0 1px 2px rgba(0,0,0,.06); } | |
| .px-rows { margin-top: 10px; } | |
| .px-row { display: grid; grid-template-columns: 150px 1fr 64px; gap: 10px; align-items: center; padding: 7px 4px; border-bottom: 1px dashed var(--line); } | |
| .doc .px-row { border-bottom: 1px dashed var(--line); } | |
| .px-row:last-child { border-bottom: 0; } | |
| .px-name { font-size: 14px; font-weight: 600; line-height: 1.25; } | |
| .px-name small { display: block; font-weight: 400; color: var(--muted); font-size: 11.5px; } | |
| .px-tag { margin-left: 6px; font-family: var(--mono); font-size: 10.5px; font-weight: 500; padding: 0 5px; border-radius: 5px; background: color-mix(in srgb, var(--accent) 35%, transparent); } | |
| .px-bar { display: flex; align-items: center; gap: 6px; height: 22px; } | |
| .px-provider { height: 8px; border-radius: 999px; background: var(--line-strong); } | |
| .px-row:first-child .px-provider { background: #f59e0b; } | |
| .px-fee { font-family: var(--mono); font-size: 11px; color: #d97706; white-space: nowrap; } | |
| .dark .px-fee { color: #fbbf24; } | |
| .px-cost { text-align: right; font-family: var(--mono); font-size: 13.5px; font-weight: 600; } | |
| .px-foot { display: flex; flex-wrap: wrap; justify-content: space-between; gap: 6px 12px; margin-top: 8px; padding: 8px 4px 0; border-top: 1px solid var(--line); font-size: 12.5px; color: var(--muted); } | |
| .px-foot b { color: var(--fg); } | |
| .px-dot { display: inline-block; width: 7px; height: 7px; border-radius: 999px; background: #16a34a; margin-right: 6px; vertical-align: middle; } | |
| .px-empty { padding: 20px; text-align: center; color: var(--muted); } | |
| @media (max-width: 1000px) { .px { grid-template-columns: 1fr; } } | |
| /* shared look for the overview blocks */ | |
| .doc .rv, .doc .mg { border: 1px solid var(--line); border-radius: 16px; background: var(--bg); } | |
| .rv-title, .mg-title { font-size: 18px; font-weight: 700; } | |
| /* <RoutingSnippet /> */ | |
| .rv { padding: 16px 18px 12px; margin: 22px 0; } | |
| .rv-head { display: flex; flex-wrap: wrap; justify-content: space-between; gap: 10px 18px; align-items: flex-start; } | |
| .rv-caption { color: var(--muted); font-size: 14.5px; max-width: 470px; min-height: 44px; margin-top: 2px; } | |
| .doc .rv-tabs { display: flex; gap: 2px; padding: 3px; border: 1px solid var(--line); border-radius: 10px; background: var(--soft); } | |
| .rv-tabs button { border: 0; background: none; color: var(--muted); border-radius: 7px; padding: 4px 10px; font-size: 13.5px; cursor: pointer; font-family: inherit; display: flex; flex-direction: column; align-items: center; line-height: 1.25; } | |
| .rv-tabs button code { font-family: var(--mono); font-size: 10.5px; background: none ; padding: 0 ; } | |
| .rv-tabs button.on { background: var(--bg); color: var(--fg); font-weight: 600; box-shadow: 0 0 0 1px var(--line); } | |
| .rv-stage { margin-top: 12px; min-height: 180px; } | |
| .rv-loading { padding: 70px 0; text-align: center; color: var(--muted); } | |
| .rv-svg { width: 100%; height: auto; display: block; } | |
| .rv-node rect { fill: var(--bg); stroke: var(--line-strong); stroke-width: 1; } | |
| .rv-router rect { stroke: var(--fg); } | |
| .rv-name { fill: var(--fg); font-size: 14px; font-weight: 600; font-family: var(--sans); } | |
| .rv-meta { fill: var(--muted); font-size: 12px; font-family: var(--mono); } | |
| .rv-mark { font-size: 15px; font-weight: 700; font-family: var(--sans); } | |
| .rv-path { fill: none; stroke: var(--line); stroke-width: 1.5; } | |
| .rv-path.hot { stroke: var(--fg); stroke-width: 1.75; } | |
| .rv-path.failed { stroke: #ef4444; stroke-dasharray: .006 .008; opacity: .7; } | |
| .rv-packet { fill: var(--fg); } | |
| .is-target rect { stroke: #16a34a; stroke-width: 1.5; } | |
| .is-target .rv-mark { fill: #16a34a; } | |
| .is-failed rect { stroke: #ef4444; stroke-dasharray: 4 3; } | |
| .is-failed .rv-mark, .is-failed .rv-meta { fill: #ef4444; } | |
| /* animated: paths draw themselves, outcomes fade in when the request arrives */ | |
| .rv-svg.animated .rv-path.hot, .rv-svg.animated .rv-path.failed { stroke-dasharray: 1; stroke-dashoffset: 1; animation: rv-draw .45s cubic-bezier(.4, 0, .2, 1) var(--t) forwards; } | |
| .rv-svg.animated .rv-path.failed { animation-name: rv-draw-failed; } | |
| .rv-svg.animated .is-target rect, .rv-svg.animated .is-failed rect { animation: rv-stroke .25s ease-out var(--t) backwards; } | |
| .rv-svg.animated .is-target .rv-mark, .rv-svg.animated .is-failed .rv-mark, .rv-svg.animated .is-failed .rv-meta { animation: rv-fade .25s ease-out var(--t) backwards; } | |
| @keyframes rv-draw { to { stroke-dashoffset: 0; } } | |
| @keyframes rv-draw-failed { 0% { stroke-dasharray: 1; stroke-dashoffset: 1; } 99% { stroke-dasharray: 1; stroke-dashoffset: 0; } 100% { stroke-dasharray: .006 .008; stroke-dashoffset: 0; } } | |
| @keyframes rv-stroke { from { stroke: var(--line-strong); stroke-width: 1; stroke-dasharray: none; } } | |
| @keyframes rv-fade { from { opacity: 0; } } | |
| .rv-foot { font-size: 12.5px; color: var(--muted); margin-top: 6px; } | |
| /* <MigrateSnippet /> */ | |
| .mg { display: grid; grid-template-columns: 1fr 1.25fr; gap: 22px; align-items: center; padding: 18px; margin: 22px 0; } | |
| .doc .mg-copy p { color: var(--muted); margin: 6px 0 12px; font-size: 14.5px; } | |
| .mg-formats { display: flex; flex-wrap: wrap; gap: 6px; } | |
| .doc .mg-formats span { font-size: 12.5px; border: 1px solid var(--line); border-radius: 999px; padding: 2px 10px; } | |
| .doc .mg-card { border: 1px solid var(--line); border-radius: 12px; overflow: hidden; background: var(--code-bg); } | |
| .doc .mg-tabs { display: flex; gap: 2px; padding: 5px; border-bottom: 1px solid var(--line); background: var(--soft); } | |
| .mg-tabs button { border: 0; background: none; color: var(--muted); padding: 4px 10px; border-radius: 7px; font-size: 13px; cursor: pointer; font-family: inherit; } | |
| .mg-tabs button.on { background: var(--bg); color: var(--fg); font-weight: 600; box-shadow: 0 0 0 1px var(--line); } | |
| .mg-diff { margin: 0; padding: 12px 0; font-family: var(--mono); font-size: 13.5px; line-height: 1.71; min-height: 230px; overflow-x: auto; } | |
| .mg-line { display: block; padding: 0 14px 0 8px; white-space: pre; color: var(--code-fg); } | |
| .mg-line i { display: inline-block; width: 18px; font-style: normal; color: var(--muted); } | |
| .mg-line.del { background: rgba(220, 38, 38, .07); color: #b91c1c; } | |
| .mg-line.del .mg-text { text-decoration: line-through; text-decoration-color: rgba(220, 38, 38, .5); } | |
| .mg-line.add { background: rgba(22, 163, 74, .08); color: #15803d; } | |
| .dark .mg-line.del { background: rgba(248, 113, 113, .09); color: #fca5a5; } | |
| .dark .mg-line.add { background: rgba(74, 222, 128, .09); color: #86efac; } | |
| /* small value cards */ | |
| .doc .vc { display: grid; grid-template-columns: repeat(3, 1fr); gap: 12px; margin: 18px 0 8px; } | |
| .doc .vc > div { border: 1px solid var(--line); border-radius: 14px; padding: 14px 16px; } | |
| .vc b { display: block; font-size: 15.5px; margin: 6px 0 2px; } | |
| .doc .vc p { margin: 0; color: var(--muted); font-size: 14px; } | |
| .vc .ico { font-size: 18px; } | |
| @media (max-width: 1000px) { .mg { grid-template-columns: 1fr; } .doc .vc { grid-template-columns: 1fr; } } | |
| @media (prefers-reduced-motion: reduce) { .rv-svg * { animation: none ; } } | |
| </style> | |
| <style> | |
| /* the iframe is the component: it fills whatever height the blog gives it, the code and the steps scroll */ | |
| html, body { height: 100%; } | |
| body { background: var(--bg); overflow: hidden; } | |
| #root { height: 100%; padding: 2px; max-width: none; } | |
| .doc .qs { height: 100%; margin: 0; } | |
| .doc .qs-card { height: 100%; display: flex; flex-direction: column; box-shadow: none; } | |
| .qs-body { flex: 1; min-height: 0; } | |
| .doc .qs-panel { display: flex; flex-direction: column; min-height: 0; } | |
| .qs-code { flex: 1; min-height: 0; overflow: auto; align-content: start; } | |
| .doc .qs-steps { flex: 1; max-height: none; min-height: 0; } | |
| .qs-models { padding-top: 10px; } | |
| .qs-stats { display: none ; } | |
| .qs-links { font-size: 13px; color: var(--muted); } | |
| .doc .qs-snippet .qs-copy { opacity: 1; } | |
| @media (max-width: 560px) { .qs-links { display: none; } .qs-surfaces { flex: none; } } | |
| .toast { position: fixed; left: 50%; bottom: 14px; transform: translateX(-50%); background: var(--fg); color: var(--bg); padding: 6px 14px; border-radius: 999px; font-size: 13.5px; opacity: 0; transition: opacity .2s; pointer-events: none; } | |
| .toast.on { opacity: 1; } | |
| </style> | |
| </head> | |
| <body> | |
| <article class="doc" id="root"></article> | |
| <div class="toast" id="toast"></div> | |
| <script> | |
| /** Logos of the coding agents, from the "Quick Setup for Agents" cards of the current overview */ | |
| const LOGOS = { | |
| "api": "<svg viewBox=\"0 0 24 24\" fill=\"none\" stroke=\"currentColor\" stroke-width=\"2\" stroke-linecap=\"round\" stroke-linejoin=\"round\" aria-hidden=\"true\"><path d=\"m8 6-6 6 6 6M16 6l6 6-6 6\"/></svg>", | |
| "claude-code": "<svg viewBox=\"0 0 12 12\" fill=\"none\" xmlns=\"http://www.w3.org/2000/svg\" aria-hidden=\"true\" role=\"img\"><g clip-path=\"url(#quick-setup-claude-clip)\"><path d=\"m2.96 7.65 1.97-1.1.03-.1-.03-.05h-.1l-.33-.02-1.12-.03-.97-.04-.95-.06-.24-.05L1 5.91l.02-.15.2-.13.29.02.63.05.95.06.69.04 1.02.11h.16L5 5.84l-.06-.04-.04-.04-.99-.66-1.06-.7-.56-.41-.3-.2-.15-.2-.07-.42.28-.3.36.03.1.02.37.29.8.61 1.03.77.16.12.06-.04v-.03l-.06-.11-.57-1.02-.6-1.04-.27-.43-.07-.26c-.03-.1-.04-.2-.04-.3l.3-.42L3.8 1l.42.06.17.15.26.59.42.93.64 1.26.2.37.1.35.03.1h.07v-.06l.05-.7.1-.88.1-1.12.03-.32.16-.38.3-.2.25.11.2.29-.03.18-.12.77-.23 1.21-.15.81h.09l.1-.1.41-.54.69-.86.3-.34.36-.38.22-.18h.43l.32.47-.14.49-.44.56-.37.47-.53.71-.33.57.03.04h.08l1.2-.26.63-.11.77-.13.35.16.04.16-.14.34-.82.2-.96.2-1.44.33-.01.01.02.03.64.06.28.02h.68l1.25.09.33.22.2.26-.03.2-.5.26-.7-.16-1.59-.38-.54-.13h-.08v.04l.46.45.83.75 1.05.97.05.24-.13.2-.15-.03-.92-.69-.35-.31-.8-.68h-.06v.08l.19.27.98 1.46.05.45-.07.15-.26.09-.28-.05-.57-.8-.59-.9-.47-.82-.06.04-.28 3.02-.13.15-.3.12-.26-.2-.14-.3.14-.62.16-.8.13-.64.12-.79.07-.26v-.02H5.9l-.6.83-.9 1.22-.73.77-.17.07-.3-.15.03-.28.17-.24 1-1.27.6-.78.38-.46v-.06h-.03L2.72 8.73l-.47.06-.2-.19.02-.3.1-.1.8-.55Z\" fill=\"#D97757\"/></g><defs><clipPath id=\"quick-setup-claude-clip\"><path fill=\"#fff\" transform=\"translate(1 1)\" d=\"M0 0h10v10H0z\"/></clipPath></defs></svg>", | |
| "codex": "<svg viewBox=\"0 0 12 12\" fill=\"none\" xmlns=\"http://www.w3.org/2000/svg\" aria-hidden=\"true\" role=\"img\"><path d=\"M10.28 5.1a2.5 2.5 0 0 0-.21-2.05 2.52 2.52 0 0 0-2.71-1.21 2.53 2.53 0 0 0-4.29.9 2.5 2.5 0 0 0-1.66 1.21 2.52 2.52 0 0 0 .3 2.96 2.5 2.5 0 0 0 .22 2.04 2.52 2.52 0 0 0 2.72 1.21 2.5 2.5 0 0 0 1.87.84 2.52 2.52 0 0 0 2.4-1.75 2.5 2.5 0 0 0 2-2.73 2.52 2.52 0 0 0-.64-1.43Zm-3.76 5.25c-.43 0-.86-.16-1.2-.44l.06-.03 2-1.15a.33.33 0 0 0 .16-.28V5.64l.84.49a.03.03 0 0 1 .02.02v2.32a1.88 1.88 0 0 1-1.88 1.88ZM2.5 8.63c-.22-.38-.3-.83-.22-1.26l.06.04 1.99 1.15a.32.32 0 0 0 .32 0l2.44-1.4v.96a.03.03 0 0 1-.02.03L5.06 9.3a1.87 1.87 0 0 1-2.56-.68Zm-.53-4.34c.23-.38.58-.67.99-.82v2.36a.32.32 0 0 0 .16.29l2.42 1.4L4.7 8a.03.03 0 0 1-.03 0l-2-1.16a1.88 1.88 0 0 1-.7-2.56v.01Zm6.92 1.6L6.46 4.5 7.3 4a.03.03 0 0 1 .03 0l2.01 1.16a1.87 1.87 0 0 1-.28 3.38V6.17a.33.33 0 0 0-.17-.27Zm.84-1.25-.06-.04-1.99-1.16a.32.32 0 0 0-.33 0l-2.43 1.4v-.97a.03.03 0 0 1 .01-.02l2.01-1.16a1.87 1.87 0 0 1 2.79 1.94ZM4.46 6.36l-.84-.49a.03.03 0 0 1-.02-.02V3.53A1.87 1.87 0 0 1 6.68 2.1l-.06.04-2 1.14a.33.33 0 0 0-.16.29v2.8Zm.46-.99L6 4.75l1.09.62v1.25L6 7.25l-1.09-.63V5.37Z\" fill=\"currentColor\"/></svg>", | |
| "opencode": "<svg viewBox=\"0 0 512 512\" fill=\"none\" xmlns=\"http://www.w3.org/2000/svg\" aria-hidden=\"true\" role=\"img\"><rect width=\"512\" height=\"512\" rx=\"96\" fill=\"#131010\"/><path d=\"M320 224V352H192V224H320Z\" fill=\"#5A5858\"/><path fill-rule=\"evenodd\" clip-rule=\"evenodd\" d=\"M384 416H128V96H384V416ZM320 160H192V352H320V160Z\" fill=\"white\"/></svg>", | |
| "pi": "<svg viewBox=\"0 0 800 800\" fill=\"none\" xmlns=\"http://www.w3.org/2000/svg\" aria-hidden=\"true\" role=\"img\"><path fill=\"currentColor\" fill-rule=\"evenodd\" d=\"M165.29 165.29H517.36V400H400V517.36H282.65V634.72H165.29ZM282.65 282.65V400H400V282.65Z\"/><path fill=\"currentColor\" d=\"M517.36 400H634.72V634.72H517.36Z\"/></svg>", | |
| "hermes": "<svg viewBox=\"0 0 12 12\" fill=\"none\" xmlns=\"http://www.w3.org/2000/svg\" aria-hidden=\"true\" role=\"img\"><path fill=\"currentColor\" d=\"M6.07.83a3.4 3.4 0 0 1 3 2.14q.16.36.28.73.12.42.2.86l.12.65.21.93a18 18 0 0 0 .4 1.5q.07.29.1.58.04.18.04.36v.38q-.03.27-.1.52-.15.4-.4.71l-.06.07h.01l.05-.02q.14-.09.23-.21.27-.3.42-.66a1.5 1.5 0 0 0 .02-1.27l-.02-.05.05.03q.07.08.13.17.2.33.21.71a1.6 1.6 0 0 1-.86 1.5q-.12.08-.26.13a.3.3 0 0 0-.13.16.2.2 0 0 0-.02.18v.06q-.01.05-.05.07-.05 0-.07-.05l-.02-.1a1 1 0 0 0-.14-.38q-.12-.22-.31-.4a1 1 0 0 0-.39-.22l-.3-.06h-.1l.24.09a2 2 0 0 1 .85.7l.1.2.03.17q0 .04-.02.06-.04.02-.07 0L9.4 11q0-.06-.03-.1a3 3 0 0 0-.62-.72 1 1 0 0 0-.23-.14 1 1 0 0 0-.5-.06q-.13 0-.27.02a1 1 0 0 0-.32.12q-.2.14-.36.3l-.41.46a1 1 0 0 0-.13.23l-.01.03-.01.02h-.16q-.04 0-.03-.03l.03-.14q.04-.21.15-.4.01-.03.05-.03v.02l.02.03q.17-.28.42-.49l.35-.24-.21.06q-.25.09-.48.25-.1.05-.18.14-.28.35-.46.76l-.02.05-.03.03h-.21q-.03 0-.02-.04l.16-.18q.2-.17.34-.38l.04-.06q.16-.2.35-.38l.12-.11.03-.04-.07.01-.04.02-.32.19q-.27.14-.52.3-.19.14-.39.24H5.4c0-.05.06-.08.05-.14l-.04.02-.14.13-.37.41h-.52l.01-.01q.03-.05.04-.12-.06-.02-.09.03l-.06.1h-.06l.08-.12v-.01h-.02l-.23.12-.07.02H2.85v-.03q.14-.1.23-.26a2 2 0 0 0 .29-.74l-.03.04-.15.18a.7.7 0 0 1-.42.2 1 1 0 0 1-.37-.05.6.6 0 0 1-.35-.46c0-.08 0-.08-.08-.1a2 2 0 0 1-.51-.25 1 1 0 0 1-.35-.49 2 2 0 0 1-.07-.53l.01-.05.02.03.04.2q.06.23.22.4a1 1 0 0 0 .4.23q.22.08.46-.01.16-.07.27-.2.2-.22.28-.52v-.05h-.01l-.04.07q-.18.32-.52.49a.7.7 0 0 1-.9-.2 1 1 0 0 1-.15-.4 1 1 0 0 1 0-.39c.02-.19.2-.5.32-.55l-.02.07-.05.15c-.06.2-.04.43.06.61q.09.16.27.2l.14.01q.1 0 .17-.05a1 1 0 0 0 .16-.21q.09-.25.13-.51l.1-.75.04-.3.03-.3.03-.3.01-.17.02-.18.03-.33q0-.04-.04-.07a1 1 0 0 1-.33-.33q-.02-.03-.06-.05a1 1 0 0 0 .2.37q.06.04.11.1h-.03l-.1-.02q-.31-.1-.55-.36-.28-.31-.3-.74-.03-.22 0-.46.05-.38.2-.75l.22-.48q.14-.24.33-.46.34-.36.75-.62a6 6 0 0 1 1.66-.77q.43-.13.86-.18l.3-.03zm-1.18 9.92q-.15.17-.29.38l-.02.04.04-.02.35-.42.02-.05h-.01zm.65-1.55-.13.13-.16.17a.4.4 0 0 1-.16.1l-.2.05h-.07l.03.06.2.31.16.29.07.17q.04.02.09-.02l.37-.18q.15-.06.28-.13l.44-.3.01-.01-.02-.02q-.18-.08-.33-.21l-.22-.18a1 1 0 0 1-.18-.28l-.03-.07zm-2.43.12q-.08.24-.24.43a.6.6 0 0 1-.33.22l-.3.03h-.07l.02.04q.06.09.17.12.1.03.22.01a1 1 0 0 0 .2-.1q.15-.13.24-.31a2 2 0 0 0 .15-.57zm6.5-2.1.02.04.03.2.03.28q.02.23 0 .45l-.05.4a3 3 0 0 1-.2.7l.03-.03.11-.1a1.4 1.4 0 0 0 .32-1.12 4 4 0 0 0-.26-.81l-.01-.02zM3.12 4.4v.07l.17.32q.03.03.01.07-.18.03-.38.11l.06.04q.04.01.04.05l-.05.03.03.02q.11.06.19.16.1.12.08.27a.7.7 0 0 1-.3.5l-.07.04-.03.05-.01.06.02.08q.06.13.17.22l.1.1a.2.2 0 0 1 0 .17l-.03.06q-.02.04 0 .07l.06.06q.01.04.06.03.08-.03.14 0 .1.02.2.08l.21.11h.05q.05-.01.07.03.01.05-.04.06l-.09.04q-.06.02-.13.03.02-.04.05-.07c-.09-.05-.28-.06-.34-.01q.03.08-.04.13c-.06-.04-.02-.08 0-.12h-.04l-.06.03-.01.04c0 .04.03.1.07.1l.15-.01h.08q-.07.06-.15.08c0 .02.03.04 0 .06q-.02.02-.05-.01l-.1-.09a.2.2 0 0 1-.07-.13q0-.04-.02-.08-.02-.05.02-.08l-.02-.03-.09-.16q-.03-.09.02-.16l.03-.05.02-.07q0-.1-.08-.17a1 1 0 0 1-.2-.23l-.01-.02-.01.02-.02.24q0 .24.07.48.08.26.2.5l.45.77a.4.4 0 0 0 .3.12q.14 0 .27-.02.19-.01.38-.05l.24-.03q.13-.01.22.1a2 2 0 0 1 .43.58q.03.06.07.01l.17-.15q.04-.04.03-.1a2 2 0 0 1-.03-.54l.02-.29.16-1 .12-.63.1-.8-.01-.53c-.01-.07 0-.07-.07-.09l-.26-.04q-.1 0-.1-.09 0-.03-.02-.06l-.01-.04-.02.12q.01.05-.05.05h-.69q-.06.02-.1-.04L4.6 4.7q-.03-.05-.08-.02l-.25.09q-.15.06-.3.17L3.84 5h-.06l.02-.06.1-.13.02-.04v-.01l-.09.01q-.1.02-.19.06-.08.02-.17-.03-.18-.15-.31-.34zm3.64 3.9-.4.26q-.05.05-.03.12l.06.13q.03.04.1.06h.14q.14-.06.23-.16a.1.1 0 0 0 .04-.13l-.06-.24-.01-.07zm-.18-.68-.2.57h.04l.34-.22q.03-.01.02-.05l-.01-.17-.03-.39-.01-.13H6.7q-.08.18-.14.4m1.47-3.9.04.12.1.31.25.84.47 1.66.06.28q0 .07.03.14l-.02-.16-.05-.28-.02-.09-.12-.51-.27-.88-.3-1.01-.06-.15-.05-.14zM3.29 7q-.04 0-.06.04a.2.2 0 0 0 .18 0zm-.12-.63q.09-.03.16.06l.02.06q0 .01-.02.02l-.15-.12zm-.34-.37v.05q.04-.02.03-.05 0-.02-.03 0m.04-.5-.02.01v.25l.03.09q.04.09.13.04.03 0 0-.04l-.05-.1c0-.02-.03-.05-.01-.08.02-.04-.04-.06-.03-.09v-.06q0-.03-.03-.03zm1.68-.62.26.1.03.02V5l-.12-.04-.14-.04c-.1-.02-.1-.02-.12 0l.25.06.35.18q.03 0 .05.04t.05.03l.1-.01-.03.04c.03.03.06 0 .1.02-.04.06-.11.04-.15.09l.03.03-.05.04c0 .05-.02.07-.14.1l.02.04-.09.02.03.05h-.1v.06l-.11-.01-.03.05h-.03q-.04-.04-.08 0h-.04l-.03-.02c-.05.04-.05.04-.1 0q-.03.04-.07 0-.05.01-.08 0-.04 0-.06-.03l-.05.02c0-.1-.09-.09-.15-.1q0-.03.04-.03h.07q.1.05.21.07l.26-.01a.5.5 0 0 0 .3-.16L5 5.41l-.01-.05-.17-.1q.03.08-.04.1v.01q.05.06 0 .12l-.1.09a.2.2 0 0 1-.28-.02l-.06-.07c-.03-.04-.03-.04-.01-.1q-.09-.06-.04-.16 0-.03.02-.07l-.04.02a.4.4 0 0 0-.15.17l-.01.02-.03-.02v-.03H4l.03-.07-.02-.02.05-.13-.06.03h-.04v-.04q.1-.17.26-.21.13-.03.25-.02zm-1.67.19a.4.4 0 0 0-.2.05q-.04.02-.02.07l.05.11q.03.07.09.03.08-.03.15-.02.12.02.21.12l.04.03h.01q0-.08-.06-.12-.1-.04-.22-.05h-.1c.1-.08.19-.02.3 0q-.06-.07-.1-.09l-.12-.06q-.04-.01-.03-.07m4.42.14a.4.4 0 0 0-.26.1l-.05.04.1.03.06-.02a.5.5 0 0 1 .39.01q.07.04.16 0l-.02-.03a.4.4 0 0 0-.2-.12Q7.4 5.2 7.3 5.2M4.06 3.68l.1.41q.08.25.2.48l.04.04q.06 0 .1-.03l-.2-.36zm1.03-2.64-.26.01-.3.07-.37.11-.04.03h.03q.27-.05.55-.02.12 0 .24.04.3.07.55.24a2.7 2.7 0 0 1 .98 1.15q.21.5.3 1.04 0 .06.07.08.08 0 .1.1 0 .07-.06.11l-.12.15.04-.01.1-.12q.06-.06.06-.14V3.8q.02-.07-.05-.07h-.04q-.05 0-.05-.06-.04-.14.1-.18l.11-.02.2-.02q.1-.02.1.07l.02.04q.02.1-.07.12l-.03.02-.02.03c-.02.06.03.16.09.19l.29.14h.03l-.01-.02-.23-.13-.08-.04-.04-.03-.01-.05a.1.1 0 0 1 .05-.08h.03q.05-.03.05-.09V3.6l-.1-.38q-.12-.46-.35-.87a3 3 0 0 0-.6-.78 2 2 0 0 0-.51-.36 2 2 0 0 0-.75-.17M8 3.6l.02.01zM2.36 2.5l-.01.02-.02.02-.16.15-.11.11a1 1 0 0 0-.24.4l.02.08h.03l-.02.07-.07.21v.04l.1-.21q.18-.45.48-.85v-.01l.01-.02m5.62 1.04zv.02H8zM2.4 2.76l-.07.1q-.03.03-.08.01-.09-.01-.12.06l-.12.25q-.04.06-.05.15h.2l-.04.12-.01.07.04-.07.08-.18q.01-.04.05-.04v.11c.05.02.03.08.04.12.04-.01.04-.09.1-.06v.08h.01l.2-.45q-.09-.01-.16.01h-.05l.1-.2v-.01l.01-.01h-.01l-.01.03-.02.01c-.05.07-.04.07-.1.05q-.05 0-.03-.07l.04-.06zm.9-.29a3 3 0 0 0-.32.48 1 1 0 0 1-.25.2l-.04.01.02-.07.1-.22H2.8l-.04.07c-.11.19-.2.36-.2.41h.04c.08.01.08.01.11-.06a.1.1 0 0 1 .07-.07l.07-.03q.03-.01.06-.01l.01.06q.02.05.02.08l.01.07.02-.04.19-.5q.07-.18.14-.33zm1.73-.1.06.21v.22c-.05-.02-.03-.07-.05-.09H5q0 .05-.02.09l-.1.1q-.03.01-.05-.02l-.02-.04-.07.05-.16.06q-.04.02-.03.06l.03.1q0 .05.05.05.16.02.28.12.03-.06.07-.07l.04-.02q.05 0 .07.03l.03.07c.02-.06-.02-.12 0-.18q.08.12.17.24v-.2l.02-.04q.07.1.1.22v-.17q0-.03.02-.04.04.04.1.07a2 2 0 0 0-.35-.7q-.06-.1-.14-.17zm-1.17.28-.08.24q-.02.06-.08.08L3.59 3h-.05l-.02-.05q-.02.05-.07.03l-.17-.1q-.03-.02-.07 0l-.06.16c-.04.12-.04.1.04.2q.03.01.07 0l.06-.01c.06 0 .12-.03.16 0l.25-.08q.03 0 .05.02 0 .03.03.05c.02-.02 0-.05.03-.07l.06.1-.02-.63zm.13.12q-.05 0-.04.05v.05q.02.13.07.25h.01l.04-.02q.02.04.06.04h.27q.06 0 .09.06 0 .01.03.03l-.03-.17-.07-.26q-.04.03-.08.02l-.06-.01zm4.43-.74q.07.1.06.21.01.11-.02.22l-.05-.03q-.07.01-.1-.05l-.12-.12-.05-.05.04.07.05.09q.03.03.02.08h-.1q-.05-.01-.06.02 0 .05-.07.04l.03.05q.03.05-.01.08l-.08.08-.04.02H7.9l-.29-.07-.04-.03-.03-.06-.06-.09v.21q.02.06-.04.05l-.14-.03-.08.01.03.1h.1q.12.01.2.1l.1.12h.01v-.02c0-.03-.03-.05 0-.08l.04.04.08.11.03.06h.02l-.19-.4h.05l.34.13q.04.01.07-.01l.07-.07q.03-.04.05 0l.11.22.07.14h.01l-.06-.15q-.04-.11-.09-.24.1.04.25.32l.02.03h.01l-.02-.06-.06-.19q-.02-.05 0-.11l.06.02-.01-.08V2.7q.03 0 .04.03l.09.14.02.02c-.02-.1-.09-.17-.1-.27l.06.04q0-.1.02-.2t-.02-.19l.02.01.12.16.03.04.02.03V2.5l-.02-.03-.14-.22q-.14-.2-.21-.22m-2.84.14c0 .07.04.12.03.18l-.16.04q.05.08-.02.14l-.06.08q-.03.02 0 .05l.06.12q.01.03.06.03h.1q.07-.02.11.06l.02.02v-.06q.01-.04.04-.04l.1-.02.03.01.03.03c0-.04-.04-.08-.01-.13l.05.02q-.02-.08-.03-.16t.05-.16q.06.05.1.11.13.17.21.36c.07-.03.12.03.18.04a1 1 0 0 0-.09-.21l-.04-.01-.08.02-.04-.05a2 2 0 0 0-.2-.34l-.1-.1-.17.11q-.03.03-.05 0l-.08-.1z\"/></svg>", | |
| }; | |
| /** | |
| * The docs prototype's `<QuickstartSnippet />`, as a page embedded in the blog post. Hub blog posts only | |
| * run scripts inside `*.hf.space` iframes, sandboxed with `allow-scripts` alone: no storage, no clipboard API, | |
| * no popups. So nothing is saved, copying falls back to `execCommand`, and links are plain text. | |
| */ | |
| const TOKEN_URL = | |
| "https://huggingface.co/settings/tokens/new?ownUserPermissions=inference.serverless.write&tokenType=fineGrained"; | |
| const DOCS = "https://huggingface.co/docs/inference-providers"; | |
| const PROMPT = "In one sentence, why do open models matter?"; | |
| const MODELS = [ | |
| { id: "thinkingmachines/Inkling-2-Small", label: "Inkling 2 Small", avatar: "https://cdn-avatars.huggingface.co/v1/production/uploads/680a76de1b8d08640089fab0/r60-JyW_pv4llgjEyDYj9.png" }, | |
| { id: "deepseek-ai/DeepSeek-V4.1-Flash-1017", label: "DeepSeek V4.1 Flash 1017", avatar: "https://cdn-avatars.huggingface.co/v1/production/uploads/6538815d1bdb3c40db94fbfa/xMBly9PUMphrFVMxLX4kq.png" }, | |
| { | |
| id: "moonshotai/Kimi-K3.1-Pro", | |
| label: "Kimi K3.1 Pro", | |
| avatar: "https://cdn-avatars.huggingface.co/v1/production/uploads/641c1e77c3983aa9490f8121/X1yT2rsaIbR9cdYGEVu0X.jpeg", | |
| }, | |
| { id: "Qwen/Qwen3.8-27B", label: "Qwen3.8 27B", avatar: "https://cdn-avatars.huggingface.co/v1/production/uploads/6215ca5692c0ecfba9186921/hrRM50-6XcdWgg2AKpENG.jpeg" }, | |
| ]; | |
| const SURFACES = [ | |
| { id: "api", label: "API" }, | |
| { id: "pi", label: "Pi", docs: "integrations/pi" }, | |
| { id: "opencode", label: "OpenCode", docs: "integrations/opencode" }, | |
| { id: "hermes", label: "Hermes Agent", docs: "integrations/hermes-agent" }, | |
| { id: "claude-code", label: "Claude Code", docs: "integrations/claude-code" }, | |
| { id: "codex", label: "Codex", docs: "integrations/codex" }, | |
| ]; | |
| const FORMATS = [ | |
| { id: "chat", label: "Chat Completions", docs: "tasks/chat-completion" }, | |
| { id: "responses", label: "Responses", docs: "guides/responses-api" }, | |
| { id: "messages", label: "Messages", docs: "tasks/chat-completion" }, | |
| { id: "hf", label: "HF SDKs", docs: "tasks/chat-completion" }, | |
| ]; | |
| const LANGS = [ | |
| { id: "python", label: "Python", hl: "python" }, | |
| { id: "typescript", label: "TypeScript", hl: "typescript" }, | |
| { id: "curl", label: "cURL", hl: "bash" }, | |
| ]; | |
| const INSTALL = { | |
| chat: { python: "pip install openai", typescript: "npm install openai" }, | |
| responses: { python: "pip install openai", typescript: "npm install openai" }, | |
| messages: { python: "pip install anthropic", typescript: "npm install @anthropic-ai/sdk" }, | |
| hf: { python: "pip install huggingface_hub", typescript: "npm install @huggingface/inference" }, | |
| }; | |
| function curl(path, body) { | |
| return `curl https://router.huggingface.co${path} \\ | |
| -H "Authorization: Bearer $HF_TOKEN" \\ | |
| -H "Content-Type: application/json" \\ | |
| -d '${JSON.stringify(body, null, 2).replace(/\n/g, "\n ")}'`; | |
| } | |
| const API_CODE = { | |
| chat: { | |
| python: m => `import os | |
| from openai import OpenAI | |
| client = OpenAI( | |
| base_url="https://router.huggingface.co/v1", | |
| api_key=os.environ["HF_TOKEN"], | |
| ) | |
| stream = client.chat.completions.create( | |
| model="${m}", | |
| messages=[{"role": "user", "content": "${PROMPT}"}], | |
| stream=True, | |
| ) | |
| for chunk in stream: | |
| print(chunk.choices[0].delta.content or "", end="")`, | |
| typescript: m => `import OpenAI from "openai"; | |
| const client = new OpenAI({ | |
| baseURL: "https://router.huggingface.co/v1", | |
| apiKey: process.env.HF_TOKEN, | |
| }); | |
| const stream = await client.chat.completions.create({ | |
| model: "${m}", | |
| messages: [{ role: "user", content: "${PROMPT}" }], | |
| stream: true, | |
| }); | |
| for await (const chunk of stream) { | |
| process.stdout.write(chunk.choices[0]?.delta?.content ?? ""); | |
| }`, | |
| curl: m => curl("/v1/chat/completions", { messages: [{ role: "user", content: PROMPT }], model: m, stream: false }), | |
| }, | |
| responses: { | |
| python: m => `import os | |
| from openai import OpenAI | |
| client = OpenAI( | |
| base_url="https://router.huggingface.co/v1", | |
| api_key=os.environ["HF_TOKEN"], | |
| ) | |
| response = client.responses.create( | |
| model="${m}", | |
| input="${PROMPT}", | |
| ) | |
| print(response.output_text)`, | |
| typescript: m => `import OpenAI from "openai"; | |
| const client = new OpenAI({ | |
| baseURL: "https://router.huggingface.co/v1", | |
| apiKey: process.env.HF_TOKEN, | |
| }); | |
| const response = await client.responses.create({ | |
| model: "${m}", | |
| input: "${PROMPT}", | |
| }); | |
| console.log(response.output_text);`, | |
| curl: m => curl("/v1/responses", { model: m, input: PROMPT }), | |
| }, | |
| messages: { | |
| python: m => `import os | |
| from anthropic import Anthropic | |
| # auth_token sends "Authorization: Bearer", which the router expects | |
| client = Anthropic( | |
| base_url="https://router.huggingface.co", | |
| auth_token=os.environ["HF_TOKEN"], | |
| ) | |
| message = client.messages.create( | |
| model="${m}", | |
| max_tokens=1024, | |
| messages=[{"role": "user", "content": "${PROMPT}"}], | |
| ) | |
| # Reasoning models put a "thinking" block before the text | |
| print(next(block.text for block in message.content if block.type == "text"))`, | |
| typescript: m => `import Anthropic from "@anthropic-ai/sdk"; | |
| // authToken sends "Authorization: Bearer", which the router expects | |
| const client = new Anthropic({ | |
| baseURL: "https://router.huggingface.co", | |
| authToken: process.env.HF_TOKEN, | |
| }); | |
| const message = await client.messages.create({ | |
| model: "${m}", | |
| max_tokens: 1024, | |
| messages: [{ role: "user", content: "${PROMPT}" }], | |
| }); | |
| // Reasoning models put a "thinking" block before the text | |
| console.log(message.content.find(block => block.type === "text")?.text);`, | |
| curl: m => curl("/v1/messages", { model: m, max_tokens: 1024, messages: [{ role: "user", content: PROMPT }] }), | |
| }, | |
| hf: { | |
| python: m => `from huggingface_hub import InferenceClient | |
| client = InferenceClient() # reads HF_TOKEN, or your \`hf auth login\` | |
| stream = client.chat.completions.create( | |
| model="${m}", | |
| messages=[{"role": "user", "content": "${PROMPT}"}], | |
| stream=True, | |
| ) | |
| for chunk in stream: | |
| print(chunk.choices[0].delta.content or "", end="")`, | |
| typescript: m => `import { InferenceClient } from "@huggingface/inference"; | |
| const client = new InferenceClient(process.env.HF_TOKEN); | |
| for await (const chunk of client.chatCompletionStream({ | |
| model: "${m}", | |
| messages: [{ role: "user", content: "${PROMPT}" }], | |
| })) { | |
| process.stdout.write(chunk.choices[0]?.delta?.content ?? ""); | |
| }`, | |
| }, | |
| }; | |
| const TOKEN_STEP = { | |
| title: "Create a Hugging Face token", | |
| text: "At **hf.co/settings/tokens**, with the **Make calls to Inference Providers** permission.", | |
| link: { href: TOKEN_URL }, | |
| }; | |
| const envTokenStep = agent => ({ | |
| title: "Add your token", | |
| text: `${agent} reads it from \`HF_TOKEN\`.`, | |
| code: `export HF_TOKEN="hf_..."`, | |
| hl: "bash", | |
| }); | |
| /** Setup steps of each coding agent for model `m` (`label` is its display name) */ | |
| const AGENT_STEPS = { | |
| "hermes": (m, label) => [ | |
| TOKEN_STEP, | |
| { title: "Install Hermes Agent", code: "curl -fsSL https://hermes-agent.nousresearch.com/install.sh | bash", hl: "bash" }, | |
| { | |
| title: "Add your token", | |
| text: "Hugging Face is built into Hermes, which reads `HF_TOKEN` from `~/.hermes/.env`.", | |
| code: `echo 'HF_TOKEN=hf_...' >> ~/.hermes/.env`, | |
| hl: "bash", | |
| }, | |
| { title: `Start Hermes with ${label}`, code: `hermes chat --provider huggingface --model ${m}`, hl: "bash" }, | |
| ], | |
| "claude-code": (m, label) => [ | |
| TOKEN_STEP, | |
| { title: "Install Claude Code", code: "curl -fsSL https://claude.ai/install.sh | bash", hl: "bash" }, | |
| { | |
| title: "Add your token", | |
| text: "Claude Code sends it as a Bearer token.", | |
| code: `export ANTHROPIC_AUTH_TOKEN="hf_..."`, | |
| hl: "bash", | |
| }, | |
| { | |
| title: "Point Claude Code at Hugging Face", | |
| text: `Every model slot uses ${label}.`, | |
| code: `export ANTHROPIC_BASE_URL="https://router.huggingface.co" | |
| export ANTHROPIC_DEFAULT_OPUS_MODEL="${m}" | |
| export ANTHROPIC_DEFAULT_SONNET_MODEL="${m}" | |
| export ANTHROPIC_DEFAULT_HAIKU_MODEL="${m}"`, | |
| hl: "bash", | |
| }, | |
| { title: "Start Claude Code", code: "claude", hl: "bash" }, | |
| ], | |
| "codex": (m, label) => [ | |
| TOKEN_STEP, | |
| { title: "Install Codex", code: "curl -fsSL https://chatgpt.com/codex/install.sh | sh", hl: "bash" }, | |
| envTokenStep("Codex"), | |
| { | |
| title: "Add Hugging Face as a provider", | |
| text: "In `~/.codex/config.toml`.", | |
| code: `[model_providers.huggingface] | |
| name = "Hugging Face" | |
| base_url = "https://router.huggingface.co/v1" | |
| env_key = "HF_TOKEN" | |
| wire_api = "responses"`, | |
| hl: "ini", | |
| }, | |
| { | |
| title: `Create a Hugging Face profile with ${label}`, | |
| text: "In `~/.codex/huggingface.config.toml`. The router doesn't support Codex's built-in web search and sub-agent tools yet, so the profile turns them off.", | |
| code: `model_provider = "huggingface" | |
| model = "${m}" | |
| web_search = "disabled" | |
| [features] | |
| multi_agent = false`, | |
| hl: "ini", | |
| }, | |
| { title: "Start Codex", code: "codex --profile huggingface", hl: "bash" }, | |
| ], | |
| "opencode": (m, label) => [ | |
| TOKEN_STEP, | |
| { title: "Install OpenCode", code: "curl -fsSL https://opencode.ai/v2/install | bash", hl: "bash" }, | |
| { | |
| title: "Log in to Hugging Face", | |
| text: "Hugging Face is built into OpenCode. Run this, select **Hugging Face** and paste your token.", | |
| code: "opencode auth login", | |
| hl: "bash", | |
| }, | |
| { title: `Start OpenCode and pick ${label}`, text: "Run `/models` in OpenCode to select the model.", code: "opencode", hl: "bash" }, | |
| ], | |
| "pi": (m, label) => [ | |
| TOKEN_STEP, | |
| { title: "Install Pi", code: "curl -fsSL https://pi.dev/install.sh | sh", hl: "bash" }, | |
| { ...envTokenStep("Pi"), text: "Hugging Face is built into Pi, which reads your token from `HF_TOKEN`." }, | |
| { title: `Start Pi and pick ${label}`, text: "Run `/model` (or press **Ctrl+L**) in Pi to select the model.", code: "pi", hl: "bash" }, | |
| ], | |
| }; | |
| const escapeHtml = s => s.replace(/[&<>"]/g, c => ({ "&": "&", "<": "<", ">": ">", '"': """ })[c]); | |
| /** Step texts use Markdown's `code` and **bold**, they're also copied as is in the agent prompt */ | |
| const inlineHtml = s => | |
| escapeHtml(s) | |
| .replace(/`([^`]+)`/g, "<code>$1</code>") | |
| .replace(/\*\*([^*]+)\*\*/g, "<b>$1</b>"); | |
| function formatPrice(n) { | |
| return n < 1 ? `$${n.toFixed(2)}` : `$${n.toFixed(n % 1 ? 2 : 0)}`; | |
| } | |
| function formatContext(n) { | |
| return n >= 1e6 ? `${Math.round(n / 1e5) / 10}M` : `${Math.round(n / 1e3)}K`; | |
| } | |
| function quickstartHtml() { | |
| return `<div class="qs" data-qs> | |
| <div class="qs-glow"></div> | |
| <div class="qs-card"> | |
| <div class="qs-body"> | |
| <div class="qs-surfaces" role="tablist"></div> | |
| <div class="qs-panel"> | |
| <div class="qs-subbar"> | |
| <div class="qs-formats"></div> | |
| <div class="qs-langs"></div> | |
| </div> | |
| <div class="qs-install"></div> | |
| <div class="qs-code"><button class="qs-copy" title="Copy code">Copy</button><div class="qs-gutter" aria-hidden="true"></div><pre><code class="hljs"></code></pre></div> | |
| <ol class="qs-steps" hidden></ol> | |
| <div class="qs-footer"> | |
| <button class="qs-agent">⧉ <span>Copy for agent</span></button> | |
| <div class="qs-links"></div> | |
| </div> | |
| </div> | |
| </div> | |
| <div class="qs-models"></div> | |
| <div class="qs-stats"></div> | |
| </div> | |
| </div>`; | |
| } | |
| /** @param {HTMLElement} root @param {{ highlight: (code: string, language: string) => string, toast: (s: string) => void }} deps */ | |
| function initQuickstart(root, { highlight, toast }) { | |
| const state = { surface: "pi", format: "chat", lang: "python", model: MODELS[0].id }; | |
| const $ = s => root.querySelector(s); | |
| function steps() { | |
| const model = MODELS.find(m => m.id === state.model); | |
| return AGENT_STEPS[state.surface](model.id, model.label); | |
| } | |
| function current() { | |
| const lang = state.format === "hf" && state.lang === "curl" ? "python" : state.lang; | |
| return { | |
| code: API_CODE[state.format][lang](state.model), | |
| hl: LANGS.find(l => l.id === lang).hl, | |
| install: INSTALL[state.format][lang] ?? "", | |
| label: `${FORMATS.find(f => f.id === state.format).label}, ${LANGS.find(l => l.id === lang).label}`, | |
| }; | |
| } | |
| function docsPath() { | |
| return state.surface === "api" | |
| ? FORMATS.find(f => f.id === state.format).docs | |
| : SURFACES.find(s => s.id === state.surface).docs; | |
| } | |
| function render() { | |
| $(".qs-surfaces").innerHTML = SURFACES.map( | |
| s => | |
| (s === SURFACES[1] ? `<div class="qs-rail-label">Coding agents</div>` : "") + | |
| `<button role="tab" data-surface="${s.id}" class="${s.id === state.surface ? "on" : ""}"><span class="qs-logo">${LOGOS[s.id]}</span>${s.label}</button>`, | |
| ).join(""); | |
| const isApi = state.surface === "api"; | |
| $(".qs-subbar").hidden = !isApi; | |
| $(".qs-formats").innerHTML = FORMATS.map( | |
| f => `<button data-format="${f.id}" class="${f.id === state.format ? "on" : ""}">${f.label}</button>`, | |
| ).join(""); | |
| $(".qs-langs").innerHTML = LANGS.map(l => { | |
| const disabled = state.format === "hf" && l.id === "curl"; | |
| const on = l.id === state.lang && !disabled; | |
| return `<button data-lang="${l.id}" class="${on ? "on" : ""}" ${disabled ? "disabled title=\"The HF SDKs are Python and JavaScript\"" : ""}>${l.label}</button>`; | |
| }).join(""); | |
| if (state.format === "hf" && state.lang === "curl") { | |
| $(".qs-langs [data-lang=python]").classList.add("on"); | |
| } | |
| $(".qs-code").hidden = !isApi; | |
| $(".qs-steps").hidden = isApi; | |
| $(".qs-install").hidden = true; | |
| if (isApi) { | |
| const { code, hl, install } = current(); | |
| $(".qs-install").innerHTML = install ? `<code>$ ${escapeHtml(install)}</code>` : ""; | |
| $(".qs-install").hidden = !install; | |
| $(".qs-code code").innerHTML = highlight(code, hl); | |
| $(".qs-gutter").textContent = code | |
| .split("\n") | |
| .map((_, i) => i + 1) | |
| .join("\n"); | |
| } else { | |
| $(".qs-steps").innerHTML = steps() | |
| .map( | |
| (step, i) => `<li> | |
| <span class="qs-num">${i + 1}</span> | |
| <div class="qs-step"> | |
| <b>${escapeHtml(step.title)}</b> | |
| ${step.text ? `<p>${inlineHtml(step.text)}</p>` : ""} | |
| ${step.code ? `<div class="qs-snippet"><button class="qs-copy" data-step="${i}" title="Copy">Copy</button><pre><code class="hljs">${highlight(step.code, step.hl)}</code></pre></div>` : ""} | |
| </div> | |
| </li>`, | |
| ) | |
| .join(""); | |
| } | |
| $(".qs-links").textContent = "Copy a step, or the whole setup as a prompt for your agent"; | |
| $(".qs-models").innerHTML = | |
| MODELS.map( | |
| m => `<button data-model="${m.id}" class="${m.id === state.model ? "on" : ""}" title="${m.id}"><img src="${m.avatar}" alt="" />${m.label}</button>`, | |
| ).join(""); | |
| } | |
| function agentPrompt() { | |
| const lines = []; | |
| if (state.surface === "api") { | |
| const { code, hl, install, label } = current(); | |
| lines.push( | |
| `# Call ${state.model} with Hugging Face Inference Providers (${label})`, | |
| "", | |
| `Create a Hugging Face token with the "Make calls to Inference Providers" permission at ${TOKEN_URL}, then set it as \`HF_TOKEN\` in the environment.`, | |
| "", | |
| ); | |
| if (install) { | |
| lines.push("```bash", install, "```", ""); | |
| } | |
| lines.push("```" + hl, code, "```", ""); | |
| } else { | |
| lines.push(`# Set up ${SURFACES.find(s => s.id === state.surface).label} with Hugging Face Inference Providers (${state.model})`, ""); | |
| steps().forEach((step, i) => { | |
| lines.push(`## ${i + 1}. ${step.title}`, ""); | |
| if (step.text) { | |
| lines.push(step.text, ""); | |
| } | |
| if (step.link) { | |
| lines.push(step.link.href, ""); | |
| } | |
| if (step.code) { | |
| lines.push("```" + (step.hl === "ini" ? "toml" : step.hl), step.code, "```", ""); | |
| } | |
| }); | |
| } | |
| lines.push( | |
| "Append `:fastest`, `:cheapest` or a provider name (e.g. `:novita`) to the model id to change routing.", | |
| "", | |
| ); | |
| lines.push(`Models list: https://router.huggingface.co/v1/models`, `Docs: ${DOCS}/${docsPath()}.md`); | |
| return lines.join("\n"); | |
| } | |
| root.addEventListener("click", async e => { | |
| const b = e.target.closest("button"); | |
| if (!b || b.disabled) { | |
| return; | |
| } | |
| if (b.dataset.surface) { | |
| state.surface = b.dataset.surface; | |
| } else if (b.dataset.format) { | |
| state.format = b.dataset.format; | |
| } else if (b.dataset.lang) { | |
| state.lang = b.dataset.lang; | |
| } else if (b.dataset.model) { | |
| state.model = b.dataset.model; | |
| } else if (b.classList.contains("qs-copy")) { | |
| copy(b.dataset.step ? steps()[b.dataset.step].code : current().code); | |
| b.textContent = "Copied"; | |
| setTimeout(() => (b.textContent = "Copy"), 1200); | |
| return; | |
| } else if (b.classList.contains("qs-agent")) { | |
| copy(agentPrompt()); | |
| toast("Copied a prompt for your agent"); | |
| return; | |
| } else { | |
| return; | |
| } | |
| render(); | |
| }); | |
| render(); | |
| } | |
| /** The Clipboard API needs a permission the blog's iframe doesn't get: copy from a selected textarea instead */ | |
| function copy(text) { | |
| const area = document.createElement("textarea"); | |
| area.value = text; | |
| area.style.cssText = "position:fixed;opacity:0"; | |
| document.body.append(area); | |
| area.select(); | |
| document.execCommand("copy"); | |
| area.remove(); | |
| } | |
| </script> | |
| <script> | |
| /// The blog follows the reader's system theme | |
| const dark = matchMedia("(prefers-color-scheme: dark)"); | |
| const theme = () => document.documentElement.classList.toggle("dark", dark.matches); | |
| theme(); | |
| dark.addEventListener("change", theme); | |
| /// escapeHtml comes from quickstart.js | |
| const root = document.getElementById("root"); | |
| root.innerHTML = quickstartHtml(); | |
| initQuickstart(root.firstElementChild, { | |
| highlight: (text, language) => (hljs.getLanguage(language) ? hljs.highlight(text, { language }).value : escapeHtml(text)), | |
| toast(text) { | |
| const t = document.getElementById("toast"); | |
| t.textContent = text; | |
| t.classList.add("on"); | |
| setTimeout(() => t.classList.remove("on"), 1400); | |
| }, | |
| }); | |
| </script> | |
| </body> | |
| </html> | |