llmapi-v2 2.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/.env.example +40 -0
- package/Dockerfile +17 -0
- package/dist/config.d.ts +48 -0
- package/dist/config.js +98 -0
- package/dist/config.js.map +1 -0
- package/dist/converter/request.d.ts +6 -0
- package/dist/converter/request.js +184 -0
- package/dist/converter/request.js.map +1 -0
- package/dist/converter/response.d.ts +6 -0
- package/dist/converter/response.js +76 -0
- package/dist/converter/response.js.map +1 -0
- package/dist/converter/stream.d.ts +54 -0
- package/dist/converter/stream.js +318 -0
- package/dist/converter/stream.js.map +1 -0
- package/dist/converter/types.d.ts +239 -0
- package/dist/converter/types.js +6 -0
- package/dist/converter/types.js.map +1 -0
- package/dist/data/posts.d.ts +19 -0
- package/dist/data/posts.js +462 -0
- package/dist/data/posts.js.map +1 -0
- package/dist/index.d.ts +1 -0
- package/dist/index.js +233 -0
- package/dist/index.js.map +1 -0
- package/dist/middleware/api-key-auth.d.ts +6 -0
- package/dist/middleware/api-key-auth.js +76 -0
- package/dist/middleware/api-key-auth.js.map +1 -0
- package/dist/middleware/quota-guard.d.ts +10 -0
- package/dist/middleware/quota-guard.js +27 -0
- package/dist/middleware/quota-guard.js.map +1 -0
- package/dist/middleware/rate-limiter.d.ts +5 -0
- package/dist/middleware/rate-limiter.js +50 -0
- package/dist/middleware/rate-limiter.js.map +1 -0
- package/dist/middleware/request-logger.d.ts +6 -0
- package/dist/middleware/request-logger.js +37 -0
- package/dist/middleware/request-logger.js.map +1 -0
- package/dist/middleware/session-auth.d.ts +19 -0
- package/dist/middleware/session-auth.js +99 -0
- package/dist/middleware/session-auth.js.map +1 -0
- package/dist/providers/aliyun.d.ts +13 -0
- package/dist/providers/aliyun.js +20 -0
- package/dist/providers/aliyun.js.map +1 -0
- package/dist/providers/base-provider.d.ts +36 -0
- package/dist/providers/base-provider.js +133 -0
- package/dist/providers/base-provider.js.map +1 -0
- package/dist/providers/deepseek.d.ts +11 -0
- package/dist/providers/deepseek.js +18 -0
- package/dist/providers/deepseek.js.map +1 -0
- package/dist/providers/registry.d.ts +18 -0
- package/dist/providers/registry.js +98 -0
- package/dist/providers/registry.js.map +1 -0
- package/dist/providers/types.d.ts +17 -0
- package/dist/providers/types.js +3 -0
- package/dist/providers/types.js.map +1 -0
- package/dist/routes/admin.d.ts +1 -0
- package/dist/routes/admin.js +153 -0
- package/dist/routes/admin.js.map +1 -0
- package/dist/routes/auth.d.ts +2 -0
- package/dist/routes/auth.js +318 -0
- package/dist/routes/auth.js.map +1 -0
- package/dist/routes/blog.d.ts +1 -0
- package/dist/routes/blog.js +29 -0
- package/dist/routes/blog.js.map +1 -0
- package/dist/routes/dashboard.d.ts +1 -0
- package/dist/routes/dashboard.js +184 -0
- package/dist/routes/dashboard.js.map +1 -0
- package/dist/routes/messages.d.ts +1 -0
- package/dist/routes/messages.js +309 -0
- package/dist/routes/messages.js.map +1 -0
- package/dist/routes/models.d.ts +1 -0
- package/dist/routes/models.js +39 -0
- package/dist/routes/models.js.map +1 -0
- package/dist/routes/payment.d.ts +1 -0
- package/dist/routes/payment.js +150 -0
- package/dist/routes/payment.js.map +1 -0
- package/dist/routes/sitemap.d.ts +1 -0
- package/dist/routes/sitemap.js +38 -0
- package/dist/routes/sitemap.js.map +1 -0
- package/dist/services/alipay.d.ts +27 -0
- package/dist/services/alipay.js +106 -0
- package/dist/services/alipay.js.map +1 -0
- package/dist/services/database.d.ts +4 -0
- package/dist/services/database.js +170 -0
- package/dist/services/database.js.map +1 -0
- package/dist/services/health-checker.d.ts +13 -0
- package/dist/services/health-checker.js +95 -0
- package/dist/services/health-checker.js.map +1 -0
- package/dist/services/mailer.d.ts +3 -0
- package/dist/services/mailer.js +91 -0
- package/dist/services/mailer.js.map +1 -0
- package/dist/services/metrics.d.ts +56 -0
- package/dist/services/metrics.js +94 -0
- package/dist/services/metrics.js.map +1 -0
- package/dist/services/remote-control.d.ts +20 -0
- package/dist/services/remote-control.js +209 -0
- package/dist/services/remote-control.js.map +1 -0
- package/dist/services/remote-ws.d.ts +5 -0
- package/dist/services/remote-ws.js +143 -0
- package/dist/services/remote-ws.js.map +1 -0
- package/dist/services/usage.d.ts +13 -0
- package/dist/services/usage.js +39 -0
- package/dist/services/usage.js.map +1 -0
- package/dist/utils/errors.d.ts +27 -0
- package/dist/utils/errors.js +48 -0
- package/dist/utils/errors.js.map +1 -0
- package/dist/utils/logger.d.ts +2 -0
- package/dist/utils/logger.js +14 -0
- package/dist/utils/logger.js.map +1 -0
- package/docker-compose.yml +19 -0
- package/package.json +39 -0
- package/public/robots.txt +8 -0
- package/src/config.ts +140 -0
- package/src/converter/request.ts +207 -0
- package/src/converter/response.ts +85 -0
- package/src/converter/stream.ts +373 -0
- package/src/converter/types.ts +257 -0
- package/src/data/posts.ts +474 -0
- package/src/index.ts +219 -0
- package/src/middleware/api-key-auth.ts +82 -0
- package/src/middleware/quota-guard.ts +28 -0
- package/src/middleware/rate-limiter.ts +61 -0
- package/src/middleware/request-logger.ts +36 -0
- package/src/middleware/session-auth.ts +91 -0
- package/src/providers/aliyun.ts +16 -0
- package/src/providers/base-provider.ts +148 -0
- package/src/providers/deepseek.ts +14 -0
- package/src/providers/registry.ts +111 -0
- package/src/providers/types.ts +26 -0
- package/src/routes/admin.ts +169 -0
- package/src/routes/auth.ts +369 -0
- package/src/routes/blog.ts +28 -0
- package/src/routes/dashboard.ts +208 -0
- package/src/routes/messages.ts +346 -0
- package/src/routes/models.ts +37 -0
- package/src/routes/payment.ts +189 -0
- package/src/routes/sitemap.ts +40 -0
- package/src/services/alipay.ts +116 -0
- package/src/services/database.ts +187 -0
- package/src/services/health-checker.ts +115 -0
- package/src/services/mailer.ts +90 -0
- package/src/services/metrics.ts +104 -0
- package/src/services/remote-control.ts +226 -0
- package/src/services/remote-ws.ts +145 -0
- package/src/services/usage.ts +57 -0
- package/src/types/express.d.ts +46 -0
- package/src/utils/errors.ts +44 -0
- package/src/utils/logger.ts +8 -0
- package/tsconfig.json +17 -0
- package/views/pages/404.ejs +14 -0
- package/views/pages/admin.ejs +307 -0
- package/views/pages/blog-post.ejs +378 -0
- package/views/pages/blog.ejs +148 -0
- package/views/pages/dashboard.ejs +441 -0
- package/views/pages/docs.ejs +807 -0
- package/views/pages/index.ejs +416 -0
- package/views/pages/login.ejs +170 -0
- package/views/pages/orders.ejs +111 -0
- package/views/pages/pricing.ejs +379 -0
- package/views/pages/register.ejs +397 -0
- package/views/pages/remote.ejs +334 -0
- package/views/pages/settings.ejs +373 -0
- package/views/partials/header.ejs +70 -0
- package/views/partials/nav.ejs +140 -0
|
@@ -0,0 +1,807 @@
|
|
|
1
|
+
<%- include('../partials/header', { pageTitle: 'API Documentation' }) %>
|
|
2
|
+
<%- include('../partials/nav') %>
|
|
3
|
+
|
|
4
|
+
<!-- SEO structured data -->
|
|
5
|
+
<script type="application/ld+json">
|
|
6
|
+
{
|
|
7
|
+
"@context": "https://schema.org",
|
|
8
|
+
"@type": "TechArticle",
|
|
9
|
+
"headline": "LLM API Documentation — Claude Code API Proxy",
|
|
10
|
+
"description": "Complete API documentation for LLM API, a high-availability Claude Code API proxy service. Includes quick start guide, authentication, endpoint reference, model mapping, error handling, and rate limits.",
|
|
11
|
+
"url": "https://llmapi.pro/docs",
|
|
12
|
+
"publisher": {
|
|
13
|
+
"@type": "Organization",
|
|
14
|
+
"name": "LLM API"
|
|
15
|
+
}
|
|
16
|
+
}
|
|
17
|
+
</script>
|
|
18
|
+
|
|
19
|
+
<div class="max-w-7xl mx-auto px-4 sm:px-6 lg:px-8 py-8">
|
|
20
|
+
<div class="flex gap-8">
|
|
21
|
+
|
|
22
|
+
<!-- Sticky sidebar navigation (desktop) -->
|
|
23
|
+
<aside class="hidden lg:block w-60 flex-shrink-0">
|
|
24
|
+
<nav class="sticky top-24 space-y-1">
|
|
25
|
+
<p class="px-3 py-2 text-xs font-semibold text-gray-400 uppercase tracking-wider">Getting Started</p>
|
|
26
|
+
<a href="#quickstart" class="doc-nav-link block px-3 py-2 text-sm font-medium rounded-lg text-claude-orange bg-orange-50">Quick Start</a>
|
|
27
|
+
<a href="#claude-code" class="doc-nav-link block px-3 py-2 text-sm font-medium rounded-lg text-gray-600 hover:text-claude-orange hover:bg-orange-50/50 transition-colors">Claude Code Integration</a>
|
|
28
|
+
<a href="#authentication" class="doc-nav-link block px-3 py-2 text-sm font-medium rounded-lg text-gray-600 hover:text-claude-orange hover:bg-orange-50/50 transition-colors">Authentication</a>
|
|
29
|
+
<p class="px-3 pt-4 pb-2 text-xs font-semibold text-gray-400 uppercase tracking-wider">Reference</p>
|
|
30
|
+
<a href="#api-reference" class="doc-nav-link block px-3 py-2 text-sm font-medium rounded-lg text-gray-600 hover:text-claude-orange hover:bg-orange-50/50 transition-colors">API Reference</a>
|
|
31
|
+
<a href="#models" class="doc-nav-link block px-3 py-2 text-sm font-medium rounded-lg text-gray-600 hover:text-claude-orange hover:bg-orange-50/50 transition-colors">Models</a>
|
|
32
|
+
<a href="#errors" class="doc-nav-link block px-3 py-2 text-sm font-medium rounded-lg text-gray-600 hover:text-claude-orange hover:bg-orange-50/50 transition-colors">Error Handling</a>
|
|
33
|
+
<a href="#rate-limits" class="doc-nav-link block px-3 py-2 text-sm font-medium rounded-lg text-gray-600 hover:text-claude-orange hover:bg-orange-50/50 transition-colors">Rate Limits</a>
|
|
34
|
+
</nav>
|
|
35
|
+
</aside>
|
|
36
|
+
|
|
37
|
+
<!-- Mobile table of contents -->
|
|
38
|
+
<div class="lg:hidden fixed bottom-4 right-4 z-40">
|
|
39
|
+
<button onclick="document.getElementById('mobileToc').classList.toggle('hidden')" class="w-12 h-12 bg-claude-orange text-white rounded-full shadow-lg flex items-center justify-center hover:bg-opacity-90 transition-colors">
|
|
40
|
+
<svg class="w-5 h-5" fill="none" stroke="currentColor" viewBox="0 0 24 24"><path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M4 6h16M4 12h16M4 18h7"/></svg>
|
|
41
|
+
</button>
|
|
42
|
+
<div id="mobileToc" class="hidden absolute bottom-14 right-0 w-56 bg-white rounded-xl shadow-xl border border-gray-100 py-2 mb-2">
|
|
43
|
+
<a href="#quickstart" onclick="document.getElementById('mobileToc').classList.add('hidden')" class="block px-4 py-2 text-sm text-gray-700 hover:bg-gray-50">Quick Start</a>
|
|
44
|
+
<a href="#claude-code" onclick="document.getElementById('mobileToc').classList.add('hidden')" class="block px-4 py-2 text-sm text-gray-700 hover:bg-gray-50">Claude Code Integration</a>
|
|
45
|
+
<a href="#authentication" onclick="document.getElementById('mobileToc').classList.add('hidden')" class="block px-4 py-2 text-sm text-gray-700 hover:bg-gray-50">Authentication</a>
|
|
46
|
+
<a href="#api-reference" onclick="document.getElementById('mobileToc').classList.add('hidden')" class="block px-4 py-2 text-sm text-gray-700 hover:bg-gray-50">API Reference</a>
|
|
47
|
+
<a href="#models" onclick="document.getElementById('mobileToc').classList.add('hidden')" class="block px-4 py-2 text-sm text-gray-700 hover:bg-gray-50">Models</a>
|
|
48
|
+
<a href="#errors" onclick="document.getElementById('mobileToc').classList.add('hidden')" class="block px-4 py-2 text-sm text-gray-700 hover:bg-gray-50">Error Handling</a>
|
|
49
|
+
<a href="#rate-limits" onclick="document.getElementById('mobileToc').classList.add('hidden')" class="block px-4 py-2 text-sm text-gray-700 hover:bg-gray-50">Rate Limits</a>
|
|
50
|
+
</div>
|
|
51
|
+
</div>
|
|
52
|
+
|
|
53
|
+
<!-- Main content -->
|
|
54
|
+
<main class="flex-1 min-w-0">
|
|
55
|
+
|
|
56
|
+
<!-- ============================================================ -->
|
|
57
|
+
<!-- QUICK START -->
|
|
58
|
+
<!-- ============================================================ -->
|
|
59
|
+
<section id="quickstart" class="mb-16 scroll-mt-24">
|
|
60
|
+
<h1 class="text-3xl font-bold text-claude-dark mb-3">API Documentation</h1>
|
|
61
|
+
<p class="text-gray-600 mb-8 leading-relaxed max-w-2xl">LLM API is a high-availability Claude Code API proxy fully compatible with the Anthropic API format. Change your Base URL and start building — no other code changes required.</p>
|
|
62
|
+
|
|
63
|
+
<!-- Base URL -->
|
|
64
|
+
<div class="bg-white rounded-xl border border-gray-100 p-6 shadow-sm mb-8">
|
|
65
|
+
<h2 class="text-lg font-semibold text-claude-dark mb-2">Base URL</h2>
|
|
66
|
+
<div class="relative">
|
|
67
|
+
<pre class="bg-gray-900 text-green-400 rounded-lg p-4 text-sm font-mono">https://llmapi.pro</pre>
|
|
68
|
+
<button onclick="copyCode(this)" class="absolute top-2 right-2 px-2 py-1 text-xs text-gray-400 bg-gray-800 rounded hover:text-white transition-colors">Copy</button>
|
|
69
|
+
</div>
|
|
70
|
+
</div>
|
|
71
|
+
|
|
72
|
+
<!-- 3-step setup -->
|
|
73
|
+
<h2 class="text-xl font-semibold text-claude-dark mb-4">Get Started in 3 Steps</h2>
|
|
74
|
+
|
|
75
|
+
<!-- Step 1 -->
|
|
76
|
+
<div class="flex items-start gap-4 mb-6">
|
|
77
|
+
<span class="flex-shrink-0 w-8 h-8 bg-claude-orange text-white rounded-full flex items-center justify-center text-sm font-bold">1</span>
|
|
78
|
+
<div class="flex-1 min-w-0">
|
|
79
|
+
<h3 class="text-base font-semibold text-claude-dark mb-2">Create an account and get your API key</h3>
|
|
80
|
+
<p class="text-sm text-gray-600 mb-3"><a href="/register" class="text-claude-orange hover:underline">Register for free</a>, then copy your API key from the <a href="/dashboard" class="text-claude-orange hover:underline">Dashboard</a>.</p>
|
|
81
|
+
</div>
|
|
82
|
+
</div>
|
|
83
|
+
|
|
84
|
+
<!-- Step 2 -->
|
|
85
|
+
<div class="flex items-start gap-4 mb-6">
|
|
86
|
+
<span class="flex-shrink-0 w-8 h-8 bg-claude-orange text-white rounded-full flex items-center justify-center text-sm font-bold">2</span>
|
|
87
|
+
<div class="flex-1 min-w-0">
|
|
88
|
+
<h3 class="text-base font-semibold text-claude-dark mb-2">Set your environment variables</h3>
|
|
89
|
+
|
|
90
|
+
<!-- OS tabs -->
|
|
91
|
+
<div class="mb-3">
|
|
92
|
+
<div class="flex border-b border-gray-200">
|
|
93
|
+
<button onclick="switchTab(this, 'setup-mac')" class="os-tab px-4 py-2 text-sm font-medium border-b-2 border-claude-orange text-claude-orange" data-group="setup">macOS / Linux</button>
|
|
94
|
+
<button onclick="switchTab(this, 'setup-win')" class="os-tab px-4 py-2 text-sm font-medium border-b-2 border-transparent text-gray-500 hover:text-gray-700" data-group="setup">Windows PowerShell</button>
|
|
95
|
+
</div>
|
|
96
|
+
</div>
|
|
97
|
+
<div id="setup-mac" class="tab-panel relative">
|
|
98
|
+
<pre class="bg-gray-900 text-green-400 rounded-lg p-4 text-sm font-mono overflow-x-auto leading-relaxed"><code>export ANTHROPIC_BASE_URL=https://llmapi.pro
|
|
99
|
+
export ANTHROPIC_API_KEY=your-api-key</code></pre>
|
|
100
|
+
<button onclick="copyCode(this)" class="absolute top-2 right-2 px-2 py-1 text-xs text-gray-400 bg-gray-800 rounded hover:text-white transition-colors">Copy</button>
|
|
101
|
+
</div>
|
|
102
|
+
<div id="setup-win" class="tab-panel relative hidden">
|
|
103
|
+
<pre class="bg-gray-900 text-green-400 rounded-lg p-4 text-sm font-mono overflow-x-auto leading-relaxed"><code>$env:ANTHROPIC_BASE_URL="https://llmapi.pro"
|
|
104
|
+
$env:ANTHROPIC_API_KEY="your-api-key"</code></pre>
|
|
105
|
+
<button onclick="copyCode(this)" class="absolute top-2 right-2 px-2 py-1 text-xs text-gray-400 bg-gray-800 rounded hover:text-white transition-colors">Copy</button>
|
|
106
|
+
</div>
|
|
107
|
+
</div>
|
|
108
|
+
</div>
|
|
109
|
+
|
|
110
|
+
<!-- Step 3 -->
|
|
111
|
+
<div class="flex items-start gap-4 mb-6">
|
|
112
|
+
<span class="flex-shrink-0 w-8 h-8 bg-claude-orange text-white rounded-full flex items-center justify-center text-sm font-bold">3</span>
|
|
113
|
+
<div class="flex-1 min-w-0">
|
|
114
|
+
<h3 class="text-base font-semibold text-claude-dark mb-2">Send your first request</h3>
|
|
115
|
+
|
|
116
|
+
<div class="mb-3">
|
|
117
|
+
<div class="flex border-b border-gray-200">
|
|
118
|
+
<button onclick="switchTab(this, 'first-curl')" class="os-tab px-4 py-2 text-sm font-medium border-b-2 border-claude-orange text-claude-orange" data-group="first">cURL (macOS/Linux)</button>
|
|
119
|
+
<button onclick="switchTab(this, 'first-win')" class="os-tab px-4 py-2 text-sm font-medium border-b-2 border-transparent text-gray-500 hover:text-gray-700" data-group="first">PowerShell</button>
|
|
120
|
+
</div>
|
|
121
|
+
</div>
|
|
122
|
+
<div id="first-curl" class="tab-panel relative">
|
|
123
|
+
<pre class="bg-gray-900 text-green-400 rounded-lg p-4 text-sm font-mono overflow-x-auto leading-relaxed"><code>curl https://llmapi.pro/v1/messages \
|
|
124
|
+
-H "Content-Type: application/json" \
|
|
125
|
+
-H "x-api-key: $ANTHROPIC_API_KEY" \
|
|
126
|
+
-H "anthropic-version: 2023-06-01" \
|
|
127
|
+
-d '{
|
|
128
|
+
"model": "claude-sonnet-4-20250514",
|
|
129
|
+
"max_tokens": 1024,
|
|
130
|
+
"messages": [
|
|
131
|
+
{"role": "user", "content": "Hello! What can you do?"}
|
|
132
|
+
]
|
|
133
|
+
}'</code></pre>
|
|
134
|
+
<button onclick="copyCode(this)" class="absolute top-2 right-2 px-2 py-1 text-xs text-gray-400 bg-gray-800 rounded hover:text-white transition-colors">Copy</button>
|
|
135
|
+
</div>
|
|
136
|
+
<div id="first-win" class="tab-panel relative hidden">
|
|
137
|
+
<pre class="bg-gray-900 text-green-400 rounded-lg p-4 text-sm font-mono overflow-x-auto leading-relaxed"><code>$body = @{
|
|
138
|
+
model = "claude-sonnet-4-20250514"
|
|
139
|
+
max_tokens = 1024
|
|
140
|
+
messages = @(
|
|
141
|
+
@{ role = "user"; content = "Hello! What can you do?" }
|
|
142
|
+
)
|
|
143
|
+
} | ConvertTo-Json -Depth 4
|
|
144
|
+
|
|
145
|
+
Invoke-RestMethod -Uri "https://llmapi.pro/v1/messages" `
|
|
146
|
+
-Method POST `
|
|
147
|
+
-Headers @{
|
|
148
|
+
"x-api-key" = $env:ANTHROPIC_API_KEY
|
|
149
|
+
"anthropic-version" = "2023-06-01"
|
|
150
|
+
"Content-Type" = "application/json"
|
|
151
|
+
} `
|
|
152
|
+
-Body $body</code></pre>
|
|
153
|
+
<button onclick="copyCode(this)" class="absolute top-2 right-2 px-2 py-1 text-xs text-gray-400 bg-gray-800 rounded hover:text-white transition-colors">Copy</button>
|
|
154
|
+
</div>
|
|
155
|
+
</div>
|
|
156
|
+
</div>
|
|
157
|
+
</section>
|
|
158
|
+
|
|
159
|
+
<!-- ============================================================ -->
|
|
160
|
+
<!-- CLAUDE CODE INTEGRATION -->
|
|
161
|
+
<!-- ============================================================ -->
|
|
162
|
+
<section id="claude-code" class="mb-16 scroll-mt-24">
|
|
163
|
+
<h2 class="text-2xl font-bold text-claude-dark mb-4">Claude Code Integration</h2>
|
|
164
|
+
<p class="text-gray-600 mb-6 leading-relaxed">Configure the <a href="https://docs.anthropic.com/en/docs/claude-code" target="_blank" rel="noopener" class="text-claude-orange hover:underline">Claude Code CLI</a> to route all requests through LLM API. Set two environment variables and launch Claude Code as usual — no plugins or patches needed.</p>
|
|
165
|
+
|
|
166
|
+
<!-- macOS / Linux -->
|
|
167
|
+
<h3 class="text-base font-semibold text-claude-dark mb-3">macOS / Linux</h3>
|
|
168
|
+
<div class="relative mb-6">
|
|
169
|
+
<pre class="bg-gray-900 text-green-400 rounded-lg p-4 text-sm font-mono overflow-x-auto leading-relaxed"><code># Temporary (current shell session only)
|
|
170
|
+
export ANTHROPIC_BASE_URL=https://llmapi.pro
|
|
171
|
+
export ANTHROPIC_API_KEY=your-api-key
|
|
172
|
+
|
|
173
|
+
# Permanent (add to ~/.bashrc or ~/.zshrc)
|
|
174
|
+
echo 'export ANTHROPIC_BASE_URL=https://llmapi.pro' >> ~/.zshrc
|
|
175
|
+
echo 'export ANTHROPIC_API_KEY=your-api-key' >> ~/.zshrc
|
|
176
|
+
source ~/.zshrc
|
|
177
|
+
|
|
178
|
+
# Then simply launch Claude Code
|
|
179
|
+
claude</code></pre>
|
|
180
|
+
<button onclick="copyCode(this)" class="absolute top-2 right-2 px-2 py-1 text-xs text-gray-400 bg-gray-800 rounded hover:text-white transition-colors">Copy</button>
|
|
181
|
+
</div>
|
|
182
|
+
|
|
183
|
+
<!-- Windows PowerShell -->
|
|
184
|
+
<h3 class="text-base font-semibold text-claude-dark mb-3">Windows PowerShell</h3>
|
|
185
|
+
<div class="relative mb-8">
|
|
186
|
+
<pre class="bg-gray-900 text-green-400 rounded-lg p-4 text-sm font-mono overflow-x-auto leading-relaxed"><code># Temporary (current session only)
|
|
187
|
+
$env:ANTHROPIC_BASE_URL="https://llmapi.pro"
|
|
188
|
+
$env:ANTHROPIC_API_KEY="your-api-key"
|
|
189
|
+
|
|
190
|
+
# Permanent (user-level environment variable)
|
|
191
|
+
[System.Environment]::SetEnvironmentVariable("ANTHROPIC_BASE_URL", "https://llmapi.pro", "User")
|
|
192
|
+
[System.Environment]::SetEnvironmentVariable("ANTHROPIC_API_KEY", "your-api-key", "User")
|
|
193
|
+
|
|
194
|
+
# Then launch Claude Code
|
|
195
|
+
claude</code></pre>
|
|
196
|
+
<button onclick="copyCode(this)" class="absolute top-2 right-2 px-2 py-1 text-xs text-gray-400 bg-gray-800 rounded hover:text-white transition-colors">Copy</button>
|
|
197
|
+
</div>
|
|
198
|
+
|
|
199
|
+
<!-- Environment variables explanation -->
|
|
200
|
+
<div class="bg-white rounded-xl border border-gray-100 p-6 shadow-sm mb-8">
|
|
201
|
+
<h3 class="text-base font-semibold text-claude-dark mb-3">Environment Variables</h3>
|
|
202
|
+
<div class="overflow-x-auto">
|
|
203
|
+
<table class="w-full text-sm">
|
|
204
|
+
<thead>
|
|
205
|
+
<tr class="border-b border-gray-100">
|
|
206
|
+
<th class="text-left py-2 px-2 font-medium text-gray-500">Variable</th>
|
|
207
|
+
<th class="text-left py-2 px-2 font-medium text-gray-500">Required</th>
|
|
208
|
+
<th class="text-left py-2 px-2 font-medium text-gray-500">Description</th>
|
|
209
|
+
</tr>
|
|
210
|
+
</thead>
|
|
211
|
+
<tbody class="text-gray-600">
|
|
212
|
+
<tr class="border-b border-gray-50">
|
|
213
|
+
<td class="py-2 px-2"><code class="text-xs font-mono bg-gray-50 px-1.5 py-0.5 rounded">ANTHROPIC_BASE_URL</code></td>
|
|
214
|
+
<td class="py-2 px-2"><span class="text-claude-orange font-medium">Yes</span></td>
|
|
215
|
+
<td class="py-2 px-2">Set to <code class="text-xs font-mono bg-gray-50 px-1 rounded">https://llmapi.pro</code> to proxy requests through LLM API.</td>
|
|
216
|
+
</tr>
|
|
217
|
+
<tr>
|
|
218
|
+
<td class="py-2 px-2"><code class="text-xs font-mono bg-gray-50 px-1.5 py-0.5 rounded">ANTHROPIC_API_KEY</code></td>
|
|
219
|
+
<td class="py-2 px-2"><span class="text-claude-orange font-medium">Yes</span></td>
|
|
220
|
+
<td class="py-2 px-2">Your LLM API key (starts with <code class="text-xs font-mono bg-gray-50 px-1 rounded">sk-llmapi-</code>). Get it from the <a href="/dashboard" class="text-claude-orange hover:underline">Dashboard</a>.</td>
|
|
221
|
+
</tr>
|
|
222
|
+
</tbody>
|
|
223
|
+
</table>
|
|
224
|
+
</div>
|
|
225
|
+
</div>
|
|
226
|
+
|
|
227
|
+
<!-- Model mapping table -->
|
|
228
|
+
<div class="bg-white rounded-xl border border-gray-100 p-6 shadow-sm">
|
|
229
|
+
<h3 class="text-base font-semibold text-claude-dark mb-2">Model Mapping</h3>
|
|
230
|
+
<p class="text-sm text-gray-600 mb-4">When Claude Code sends a request, LLM API transparently maps model identifiers to the best-available backend. You can use any standard Anthropic model name.</p>
|
|
231
|
+
<div class="overflow-x-auto">
|
|
232
|
+
<table class="w-full text-sm">
|
|
233
|
+
<thead>
|
|
234
|
+
<tr class="border-b border-gray-100">
|
|
235
|
+
<th class="text-left py-2 px-2 font-medium text-gray-500">Model Name</th>
|
|
236
|
+
<th class="text-left py-2 px-2 font-medium text-gray-500">Optimized For</th>
|
|
237
|
+
<th class="text-left py-2 px-2 font-medium text-gray-500">Notes</th>
|
|
238
|
+
</tr>
|
|
239
|
+
</thead>
|
|
240
|
+
<tbody class="text-gray-600">
|
|
241
|
+
<tr class="border-b border-gray-50">
|
|
242
|
+
<td class="py-2 px-2"><code class="text-xs font-mono bg-gray-50 px-1.5 py-0.5 rounded">claude-sonnet-4-6</code></td>
|
|
243
|
+
<td class="py-2 px-2">Code generation & tool use</td>
|
|
244
|
+
<td class="py-2 px-2">Default Claude Code model. Routed to our best coding model.</td>
|
|
245
|
+
</tr>
|
|
246
|
+
<tr class="border-b border-gray-50">
|
|
247
|
+
<td class="py-2 px-2"><code class="text-xs font-mono bg-gray-50 px-1.5 py-0.5 rounded">claude-opus-4-6</code></td>
|
|
248
|
+
<td class="py-2 px-2">Complex reasoning</td>
|
|
249
|
+
<td class="py-2 px-2">Highest-capability model for architecture and design tasks.</td>
|
|
250
|
+
</tr>
|
|
251
|
+
<tr class="border-b border-gray-50">
|
|
252
|
+
<td class="py-2 px-2"><code class="text-xs font-mono bg-gray-50 px-1.5 py-0.5 rounded">claude-haiku-4-5</code></td>
|
|
253
|
+
<td class="py-2 px-2">Fast & affordable</td>
|
|
254
|
+
<td class="py-2 px-2">Quick responses for simple tasks. Lowest cost per token.</td>
|
|
255
|
+
</tr>
|
|
256
|
+
</tbody>
|
|
257
|
+
</table>
|
|
258
|
+
</div>
|
|
259
|
+
<div class="mt-4 p-3 bg-blue-50 border border-blue-200 rounded-lg">
|
|
260
|
+
<p class="text-sm text-blue-800"><strong>Tip:</strong> Model routing is handled automatically. You do not need to change the model parameter in Claude Code — LLM API takes care of it.</p>
|
|
261
|
+
</div>
|
|
262
|
+
</div>
|
|
263
|
+
</section>
|
|
264
|
+
|
|
265
|
+
<!-- ============================================================ -->
|
|
266
|
+
<!-- AUTHENTICATION -->
|
|
267
|
+
<!-- ============================================================ -->
|
|
268
|
+
<section id="authentication" class="mb-16 scroll-mt-24">
|
|
269
|
+
<h2 class="text-2xl font-bold text-claude-dark mb-4">Authentication</h2>
|
|
270
|
+
<p class="text-gray-600 mb-6 leading-relaxed">Every API request must include a valid API key. You can pass your key using either of the two headers below. Create and manage keys in your <a href="/dashboard" class="text-claude-orange hover:underline">Dashboard</a>.</p>
|
|
271
|
+
|
|
272
|
+
<div class="bg-white rounded-xl border border-gray-100 p-6 shadow-sm mb-6">
|
|
273
|
+
<h3 class="text-base font-semibold text-claude-dark mb-3">Supported Auth Headers</h3>
|
|
274
|
+
<div class="overflow-x-auto">
|
|
275
|
+
<table class="w-full text-sm">
|
|
276
|
+
<thead>
|
|
277
|
+
<tr class="border-b border-gray-100">
|
|
278
|
+
<th class="text-left py-2 px-2 font-medium text-gray-500">Header</th>
|
|
279
|
+
<th class="text-left py-2 px-2 font-medium text-gray-500">Format</th>
|
|
280
|
+
<th class="text-left py-2 px-2 font-medium text-gray-500">Description</th>
|
|
281
|
+
</tr>
|
|
282
|
+
</thead>
|
|
283
|
+
<tbody class="text-gray-600">
|
|
284
|
+
<tr class="border-b border-gray-50">
|
|
285
|
+
<td class="py-2 px-2"><code class="text-xs font-mono bg-gray-50 px-1.5 py-0.5 rounded">x-api-key</code></td>
|
|
286
|
+
<td class="py-2 px-2"><code class="text-xs font-mono bg-gray-50 px-1 rounded">sk-llmapi-xxxx</code></td>
|
|
287
|
+
<td class="py-2 px-2">Primary method. Compatible with the Anthropic SDK.</td>
|
|
288
|
+
</tr>
|
|
289
|
+
<tr>
|
|
290
|
+
<td class="py-2 px-2"><code class="text-xs font-mono bg-gray-50 px-1.5 py-0.5 rounded">Authorization</code></td>
|
|
291
|
+
<td class="py-2 px-2"><code class="text-xs font-mono bg-gray-50 px-1 rounded">Bearer sk-llmapi-xxxx</code></td>
|
|
292
|
+
<td class="py-2 px-2">Alternative Bearer-token method.</td>
|
|
293
|
+
</tr>
|
|
294
|
+
</tbody>
|
|
295
|
+
</table>
|
|
296
|
+
</div>
|
|
297
|
+
</div>
|
|
298
|
+
|
|
299
|
+
<h3 class="text-base font-semibold text-claude-dark mb-3">Example: cURL with x-api-key</h3>
|
|
300
|
+
<div class="relative mb-6">
|
|
301
|
+
<pre class="bg-gray-900 text-green-400 rounded-lg p-4 text-sm font-mono overflow-x-auto leading-relaxed"><code>curl https://llmapi.pro/v1/messages \
|
|
302
|
+
-H "Content-Type: application/json" \
|
|
303
|
+
-H "x-api-key: sk-llmapi-xxxxxxxxxxxxxxxxxxxxxxxx" \
|
|
304
|
+
-H "anthropic-version: 2023-06-01" \
|
|
305
|
+
-d '{
|
|
306
|
+
"model": "claude-sonnet-4-20250514",
|
|
307
|
+
"max_tokens": 1024,
|
|
308
|
+
"messages": [
|
|
309
|
+
{"role": "user", "content": "Explain quantum computing in simple terms."}
|
|
310
|
+
]
|
|
311
|
+
}'</code></pre>
|
|
312
|
+
<button onclick="copyCode(this)" class="absolute top-2 right-2 px-2 py-1 text-xs text-gray-400 bg-gray-800 rounded hover:text-white transition-colors">Copy</button>
|
|
313
|
+
</div>
|
|
314
|
+
|
|
315
|
+
<div class="p-3 bg-yellow-50 border border-yellow-200 rounded-lg">
|
|
316
|
+
<p class="text-sm text-yellow-800"><strong>Security note:</strong> Never expose your API key in client-side code or public repositories. If a key is compromised, delete it immediately from the Dashboard and create a new one.</p>
|
|
317
|
+
</div>
|
|
318
|
+
</section>
|
|
319
|
+
|
|
320
|
+
<!-- ============================================================ -->
|
|
321
|
+
<!-- API REFERENCE -->
|
|
322
|
+
<!-- ============================================================ -->
|
|
323
|
+
<section id="api-reference" class="mb-16 scroll-mt-24">
|
|
324
|
+
<h2 class="text-2xl font-bold text-claude-dark mb-4">API Reference</h2>
|
|
325
|
+
|
|
326
|
+
<!-- POST /v1/messages -->
|
|
327
|
+
<div class="bg-white rounded-xl border border-gray-100 p-6 shadow-sm mb-8">
|
|
328
|
+
<div class="flex items-center space-x-3 mb-2">
|
|
329
|
+
<span class="px-2.5 py-1 bg-green-100 text-green-700 text-xs font-bold rounded">POST</span>
|
|
330
|
+
<code class="text-sm font-mono text-claude-dark">/v1/messages</code>
|
|
331
|
+
</div>
|
|
332
|
+
<p class="text-gray-600 text-sm mb-6">Create a message. Fully compatible with the <a href="https://docs.anthropic.com/en/api/messages" target="_blank" rel="noopener" class="text-claude-orange hover:underline">Anthropic Messages API</a>.</p>
|
|
333
|
+
|
|
334
|
+
<h3 class="text-base font-semibold text-claude-dark mb-3">Request Parameters</h3>
|
|
335
|
+
<div class="overflow-x-auto">
|
|
336
|
+
<table class="w-full text-sm">
|
|
337
|
+
<thead>
|
|
338
|
+
<tr class="border-b border-gray-100">
|
|
339
|
+
<th class="text-left py-2 px-2 font-medium text-gray-500">Parameter</th>
|
|
340
|
+
<th class="text-left py-2 px-2 font-medium text-gray-500">Type</th>
|
|
341
|
+
<th class="text-left py-2 px-2 font-medium text-gray-500">Required</th>
|
|
342
|
+
<th class="text-left py-2 px-2 font-medium text-gray-500">Description</th>
|
|
343
|
+
</tr>
|
|
344
|
+
</thead>
|
|
345
|
+
<tbody class="text-gray-600">
|
|
346
|
+
<tr class="border-b border-gray-50">
|
|
347
|
+
<td class="py-2 px-2"><code class="text-xs font-mono bg-gray-50 px-1 rounded">model</code></td>
|
|
348
|
+
<td class="py-2 px-2">string</td>
|
|
349
|
+
<td class="py-2 px-2"><span class="text-claude-orange font-medium">Yes</span></td>
|
|
350
|
+
<td class="py-2 px-2">Model identifier, e.g. <code class="text-xs font-mono bg-gray-50 px-1 rounded">claude-sonnet-4-20250514</code></td>
|
|
351
|
+
</tr>
|
|
352
|
+
<tr class="border-b border-gray-50">
|
|
353
|
+
<td class="py-2 px-2"><code class="text-xs font-mono bg-gray-50 px-1 rounded">messages</code></td>
|
|
354
|
+
<td class="py-2 px-2">array</td>
|
|
355
|
+
<td class="py-2 px-2"><span class="text-claude-orange font-medium">Yes</span></td>
|
|
356
|
+
<td class="py-2 px-2">Array of message objects with <code class="text-xs font-mono bg-gray-50 px-1 rounded">role</code> (<code class="text-xs font-mono">user</code> | <code class="text-xs font-mono">assistant</code>) and <code class="text-xs font-mono bg-gray-50 px-1 rounded">content</code>.</td>
|
|
357
|
+
</tr>
|
|
358
|
+
<tr class="border-b border-gray-50">
|
|
359
|
+
<td class="py-2 px-2"><code class="text-xs font-mono bg-gray-50 px-1 rounded">max_tokens</code></td>
|
|
360
|
+
<td class="py-2 px-2">integer</td>
|
|
361
|
+
<td class="py-2 px-2"><span class="text-claude-orange font-medium">Yes</span></td>
|
|
362
|
+
<td class="py-2 px-2">Maximum number of tokens to generate in the response.</td>
|
|
363
|
+
</tr>
|
|
364
|
+
<tr class="border-b border-gray-50">
|
|
365
|
+
<td class="py-2 px-2"><code class="text-xs font-mono bg-gray-50 px-1 rounded">system</code></td>
|
|
366
|
+
<td class="py-2 px-2">string</td>
|
|
367
|
+
<td class="py-2 px-2">No</td>
|
|
368
|
+
<td class="py-2 px-2">System prompt that sets behavior and context for the model.</td>
|
|
369
|
+
</tr>
|
|
370
|
+
<tr class="border-b border-gray-50">
|
|
371
|
+
<td class="py-2 px-2"><code class="text-xs font-mono bg-gray-50 px-1 rounded">temperature</code></td>
|
|
372
|
+
<td class="py-2 px-2">number</td>
|
|
373
|
+
<td class="py-2 px-2">No</td>
|
|
374
|
+
<td class="py-2 px-2">Sampling temperature between 0 and 1. Lower values are more deterministic.</td>
|
|
375
|
+
</tr>
|
|
376
|
+
<tr class="border-b border-gray-50">
|
|
377
|
+
<td class="py-2 px-2"><code class="text-xs font-mono bg-gray-50 px-1 rounded">tools</code></td>
|
|
378
|
+
<td class="py-2 px-2">array</td>
|
|
379
|
+
<td class="py-2 px-2">No</td>
|
|
380
|
+
<td class="py-2 px-2">List of tool definitions the model may use (function calling).</td>
|
|
381
|
+
</tr>
|
|
382
|
+
<tr class="border-b border-gray-50">
|
|
383
|
+
<td class="py-2 px-2"><code class="text-xs font-mono bg-gray-50 px-1 rounded">tool_choice</code></td>
|
|
384
|
+
<td class="py-2 px-2">object</td>
|
|
385
|
+
<td class="py-2 px-2">No</td>
|
|
386
|
+
<td class="py-2 px-2">Controls tool use: <code class="text-xs font-mono">auto</code>, <code class="text-xs font-mono">any</code>, or <code class="text-xs font-mono">tool</code> with a specific name.</td>
|
|
387
|
+
</tr>
|
|
388
|
+
<tr>
|
|
389
|
+
<td class="py-2 px-2"><code class="text-xs font-mono bg-gray-50 px-1 rounded">stream</code></td>
|
|
390
|
+
<td class="py-2 px-2">boolean</td>
|
|
391
|
+
<td class="py-2 px-2">No</td>
|
|
392
|
+
<td class="py-2 px-2">Enable Server-Sent Events streaming. Default: <code class="text-xs font-mono">false</code>.</td>
|
|
393
|
+
</tr>
|
|
394
|
+
</tbody>
|
|
395
|
+
</table>
|
|
396
|
+
</div>
|
|
397
|
+
</div>
|
|
398
|
+
|
|
399
|
+
<!-- Non-streaming response -->
|
|
400
|
+
<h3 class="text-base font-semibold text-claude-dark mb-3">Non-Streaming Response</h3>
|
|
401
|
+
<p class="text-sm text-gray-600 mb-3">When <code class="text-xs font-mono bg-gray-100 px-1.5 py-0.5 rounded">stream</code> is <code class="text-xs font-mono">false</code> (default), the API returns a single JSON object:</p>
|
|
402
|
+
<div class="relative mb-8">
|
|
403
|
+
<pre class="bg-gray-900 text-green-400 rounded-lg p-4 text-sm font-mono overflow-x-auto leading-relaxed"><code>{
|
|
404
|
+
"id": "msg_01XFDUDYJgAACzvnptvVoYEL",
|
|
405
|
+
"type": "message",
|
|
406
|
+
"role": "assistant",
|
|
407
|
+
"content": [
|
|
408
|
+
{
|
|
409
|
+
"type": "text",
|
|
410
|
+
"text": "Hello! I can help you with a wide range of tasks..."
|
|
411
|
+
}
|
|
412
|
+
],
|
|
413
|
+
"model": "claude-sonnet-4-20250514",
|
|
414
|
+
"stop_reason": "end_turn",
|
|
415
|
+
"stop_sequence": null,
|
|
416
|
+
"usage": {
|
|
417
|
+
"input_tokens": 12,
|
|
418
|
+
"output_tokens": 58
|
|
419
|
+
}
|
|
420
|
+
}</code></pre>
|
|
421
|
+
<button onclick="copyCode(this)" class="absolute top-2 right-2 px-2 py-1 text-xs text-gray-400 bg-gray-800 rounded hover:text-white transition-colors">Copy</button>
|
|
422
|
+
</div>
|
|
423
|
+
|
|
424
|
+
<!-- Streaming response -->
|
|
425
|
+
<h3 class="text-base font-semibold text-claude-dark mb-3">Streaming Response (SSE)</h3>
|
|
426
|
+
<p class="text-sm text-gray-600 mb-3">When <code class="text-xs font-mono bg-gray-100 px-1.5 py-0.5 rounded">stream</code> is <code class="text-xs font-mono">true</code>, the response is delivered as Server-Sent Events. Each event has an <code class="text-xs font-mono bg-gray-100 px-1 rounded">event</code> field and a JSON <code class="text-xs font-mono bg-gray-100 px-1 rounded">data</code> field:</p>
|
|
427
|
+
<div class="relative mb-6">
|
|
428
|
+
<pre class="bg-gray-900 text-green-400 rounded-lg p-4 text-sm font-mono overflow-x-auto leading-relaxed"><code>event: message_start
|
|
429
|
+
data: {"type":"message_start","message":{"id":"msg_01...","type":"message","role":"assistant","content":[],"model":"claude-sonnet-4-20250514","usage":{"input_tokens":12,"output_tokens":0}}}
|
|
430
|
+
|
|
431
|
+
event: content_block_start
|
|
432
|
+
data: {"type":"content_block_start","index":0,"content_block":{"type":"text","text":""}}
|
|
433
|
+
|
|
434
|
+
event: content_block_delta
|
|
435
|
+
data: {"type":"content_block_delta","index":0,"delta":{"type":"text_delta","text":"Hello"}}
|
|
436
|
+
|
|
437
|
+
event: content_block_delta
|
|
438
|
+
data: {"type":"content_block_delta","index":0,"delta":{"type":"text_delta","text":"! I can"}}
|
|
439
|
+
|
|
440
|
+
event: content_block_stop
|
|
441
|
+
data: {"type":"content_block_stop","index":0}
|
|
442
|
+
|
|
443
|
+
event: message_delta
|
|
444
|
+
data: {"type":"message_delta","delta":{"stop_reason":"end_turn","stop_sequence":null},"usage":{"output_tokens":58}}
|
|
445
|
+
|
|
446
|
+
event: message_stop
|
|
447
|
+
data: {"type":"message_stop"}</code></pre>
|
|
448
|
+
<button onclick="copyCode(this)" class="absolute top-2 right-2 px-2 py-1 text-xs text-gray-400 bg-gray-800 rounded hover:text-white transition-colors">Copy</button>
|
|
449
|
+
</div>
|
|
450
|
+
|
|
451
|
+
<div class="bg-white rounded-xl border border-gray-100 p-6 shadow-sm">
|
|
452
|
+
<h4 class="text-sm font-semibold text-claude-dark mb-3">SSE Event Types</h4>
|
|
453
|
+
<div class="overflow-x-auto">
|
|
454
|
+
<table class="w-full text-sm">
|
|
455
|
+
<thead>
|
|
456
|
+
<tr class="border-b border-gray-100">
|
|
457
|
+
<th class="text-left py-2 px-2 font-medium text-gray-500">Event</th>
|
|
458
|
+
<th class="text-left py-2 px-2 font-medium text-gray-500">Description</th>
|
|
459
|
+
</tr>
|
|
460
|
+
</thead>
|
|
461
|
+
<tbody class="text-gray-600">
|
|
462
|
+
<tr class="border-b border-gray-50">
|
|
463
|
+
<td class="py-2 px-2"><code class="text-xs font-mono bg-gray-50 px-1 rounded">message_start</code></td>
|
|
464
|
+
<td class="py-2 px-2">Sent once at the beginning. Contains the message object with metadata.</td>
|
|
465
|
+
</tr>
|
|
466
|
+
<tr class="border-b border-gray-50">
|
|
467
|
+
<td class="py-2 px-2"><code class="text-xs font-mono bg-gray-50 px-1 rounded">content_block_start</code></td>
|
|
468
|
+
<td class="py-2 px-2">Marks the start of a new content block (text or tool_use).</td>
|
|
469
|
+
</tr>
|
|
470
|
+
<tr class="border-b border-gray-50">
|
|
471
|
+
<td class="py-2 px-2"><code class="text-xs font-mono bg-gray-50 px-1 rounded">content_block_delta</code></td>
|
|
472
|
+
<td class="py-2 px-2">Incremental content update. Concatenate <code class="text-xs font-mono">delta.text</code> to build the full response.</td>
|
|
473
|
+
</tr>
|
|
474
|
+
<tr class="border-b border-gray-50">
|
|
475
|
+
<td class="py-2 px-2"><code class="text-xs font-mono bg-gray-50 px-1 rounded">content_block_stop</code></td>
|
|
476
|
+
<td class="py-2 px-2">The content block is complete.</td>
|
|
477
|
+
</tr>
|
|
478
|
+
<tr class="border-b border-gray-50">
|
|
479
|
+
<td class="py-2 px-2"><code class="text-xs font-mono bg-gray-50 px-1 rounded">message_delta</code></td>
|
|
480
|
+
<td class="py-2 px-2">Final message metadata including <code class="text-xs font-mono">stop_reason</code> and total usage.</td>
|
|
481
|
+
</tr>
|
|
482
|
+
<tr>
|
|
483
|
+
<td class="py-2 px-2"><code class="text-xs font-mono bg-gray-50 px-1 rounded">message_stop</code></td>
|
|
484
|
+
<td class="py-2 px-2">End of stream. Close the connection.</td>
|
|
485
|
+
</tr>
|
|
486
|
+
</tbody>
|
|
487
|
+
</table>
|
|
488
|
+
</div>
|
|
489
|
+
</div>
|
|
490
|
+
</section>
|
|
491
|
+
|
|
492
|
+
<!-- ============================================================ -->
|
|
493
|
+
<!-- MODELS -->
|
|
494
|
+
<!-- ============================================================ -->
|
|
495
|
+
<section id="models" class="mb-16 scroll-mt-24">
|
|
496
|
+
<h2 class="text-2xl font-bold text-claude-dark mb-4">Models</h2>
|
|
497
|
+
<p class="text-gray-600 mb-6 leading-relaxed">LLM API accepts all standard Anthropic model identifiers. Requests are routed to the optimal backend provider for reliability and performance.</p>
|
|
498
|
+
|
|
499
|
+
<div class="bg-white rounded-xl border border-gray-100 shadow-sm overflow-hidden">
|
|
500
|
+
<div class="overflow-x-auto">
|
|
501
|
+
<table class="w-full text-sm">
|
|
502
|
+
<thead>
|
|
503
|
+
<tr class="border-b border-gray-100 bg-gray-50/50">
|
|
504
|
+
<th class="text-left py-3 px-4 font-medium text-gray-500">Model ID</th>
|
|
505
|
+
<th class="text-left py-3 px-4 font-medium text-gray-500">Display Name</th>
|
|
506
|
+
<th class="text-left py-3 px-4 font-medium text-gray-500">Best For</th>
|
|
507
|
+
<th class="text-left py-3 px-4 font-medium text-gray-500">Context Window</th>
|
|
508
|
+
</tr>
|
|
509
|
+
</thead>
|
|
510
|
+
<tbody class="text-gray-600">
|
|
511
|
+
<tr class="border-b border-gray-50">
|
|
512
|
+
<td class="py-3 px-4"><code class="text-xs font-mono bg-gray-50 px-1.5 py-0.5 rounded">claude-opus-4-20250514</code></td>
|
|
513
|
+
<td class="py-3 px-4 font-medium">Claude Opus 4</td>
|
|
514
|
+
<td class="py-3 px-4">Complex reasoning, advanced coding, deep analysis</td>
|
|
515
|
+
<td class="py-3 px-4">200K tokens</td>
|
|
516
|
+
</tr>
|
|
517
|
+
<tr class="border-b border-gray-50">
|
|
518
|
+
<td class="py-3 px-4"><code class="text-xs font-mono bg-gray-50 px-1.5 py-0.5 rounded">claude-sonnet-4-20250514</code></td>
|
|
519
|
+
<td class="py-3 px-4 font-medium">Claude Sonnet 4</td>
|
|
520
|
+
<td class="py-3 px-4">Balanced performance, everyday coding, general tasks</td>
|
|
521
|
+
<td class="py-3 px-4">200K tokens</td>
|
|
522
|
+
</tr>
|
|
523
|
+
<tr>
|
|
524
|
+
<td class="py-3 px-4"><code class="text-xs font-mono bg-gray-50 px-1.5 py-0.5 rounded">claude-haiku-4-20250514</code></td>
|
|
525
|
+
<td class="py-3 px-4 font-medium">Claude Haiku 4</td>
|
|
526
|
+
<td class="py-3 px-4">Fast responses, simple tasks, high-throughput workloads</td>
|
|
527
|
+
<td class="py-3 px-4">200K tokens</td>
|
|
528
|
+
</tr>
|
|
529
|
+
</tbody>
|
|
530
|
+
</table>
|
|
531
|
+
</div>
|
|
532
|
+
</div>
|
|
533
|
+
<p class="text-sm text-gray-500 mt-3">All official Anthropic model identifiers are supported, including versioned aliases.</p>
|
|
534
|
+
</section>
|
|
535
|
+
|
|
536
|
+
<!-- ============================================================ -->
|
|
537
|
+
<!-- ERROR HANDLING -->
|
|
538
|
+
<!-- ============================================================ -->
|
|
539
|
+
<section id="errors" class="mb-16 scroll-mt-24">
|
|
540
|
+
<h2 class="text-2xl font-bold text-claude-dark mb-4">Error Handling</h2>
|
|
541
|
+
<p class="text-gray-600 mb-6 leading-relaxed">LLM API uses standard HTTP status codes. Error responses always return a JSON body with a machine-readable <code class="text-xs font-mono bg-gray-100 px-1.5 py-0.5 rounded">type</code> and a human-readable <code class="text-xs font-mono bg-gray-100 px-1.5 py-0.5 rounded">message</code>.</p>
|
|
542
|
+
|
|
543
|
+
<!-- Error response format -->
|
|
544
|
+
<h3 class="text-base font-semibold text-claude-dark mb-3">Error Response Format</h3>
|
|
545
|
+
<div class="relative mb-8">
|
|
546
|
+
<pre class="bg-gray-900 text-green-400 rounded-lg p-4 text-sm font-mono overflow-x-auto leading-relaxed"><code>{
|
|
547
|
+
"type": "error",
|
|
548
|
+
"error": {
|
|
549
|
+
"type": "authentication_error",
|
|
550
|
+
"message": "Invalid API key provided."
|
|
551
|
+
}
|
|
552
|
+
}</code></pre>
|
|
553
|
+
<button onclick="copyCode(this)" class="absolute top-2 right-2 px-2 py-1 text-xs text-gray-400 bg-gray-800 rounded hover:text-white transition-colors">Copy</button>
|
|
554
|
+
</div>
|
|
555
|
+
|
|
556
|
+
<!-- Status codes -->
|
|
557
|
+
<h3 class="text-base font-semibold text-claude-dark mb-3">HTTP Status Codes</h3>
|
|
558
|
+
<div class="bg-white rounded-xl border border-gray-100 shadow-sm overflow-hidden">
|
|
559
|
+
<div class="overflow-x-auto">
|
|
560
|
+
<table class="w-full text-sm">
|
|
561
|
+
<thead>
|
|
562
|
+
<tr class="border-b border-gray-100 bg-gray-50/50">
|
|
563
|
+
<th class="text-left py-3 px-4 font-medium text-gray-500">Status</th>
|
|
564
|
+
<th class="text-left py-3 px-4 font-medium text-gray-500">Error Type</th>
|
|
565
|
+
<th class="text-left py-3 px-4 font-medium text-gray-500">Description</th>
|
|
566
|
+
<th class="text-left py-3 px-4 font-medium text-gray-500">Recommended Action</th>
|
|
567
|
+
</tr>
|
|
568
|
+
</thead>
|
|
569
|
+
<tbody class="text-gray-600">
|
|
570
|
+
<tr class="border-b border-gray-50">
|
|
571
|
+
<td class="py-3 px-4"><code class="text-xs font-mono bg-red-50 text-red-700 px-1.5 py-0.5 rounded">400</code></td>
|
|
572
|
+
<td class="py-3 px-4"><code class="text-xs font-mono">invalid_request_error</code></td>
|
|
573
|
+
<td class="py-3 px-4">Malformed request body or missing required parameters.</td>
|
|
574
|
+
<td class="py-3 px-4">Verify your JSON payload and required fields.</td>
|
|
575
|
+
</tr>
|
|
576
|
+
<tr class="border-b border-gray-50">
|
|
577
|
+
<td class="py-3 px-4"><code class="text-xs font-mono bg-red-50 text-red-700 px-1.5 py-0.5 rounded">401</code></td>
|
|
578
|
+
<td class="py-3 px-4"><code class="text-xs font-mono">authentication_error</code></td>
|
|
579
|
+
<td class="py-3 px-4">Invalid or missing API key.</td>
|
|
580
|
+
<td class="py-3 px-4">Check that <code class="text-xs font-mono">x-api-key</code> is set correctly.</td>
|
|
581
|
+
</tr>
|
|
582
|
+
<tr class="border-b border-gray-50">
|
|
583
|
+
<td class="py-3 px-4"><code class="text-xs font-mono bg-red-50 text-red-700 px-1.5 py-0.5 rounded">403</code></td>
|
|
584
|
+
<td class="py-3 px-4"><code class="text-xs font-mono">permission_error</code></td>
|
|
585
|
+
<td class="py-3 px-4">Insufficient permissions or account suspended.</td>
|
|
586
|
+
<td class="py-3 px-4">Verify your account status and plan entitlements.</td>
|
|
587
|
+
</tr>
|
|
588
|
+
<tr class="border-b border-gray-50">
|
|
589
|
+
<td class="py-3 px-4"><code class="text-xs font-mono bg-yellow-50 text-yellow-700 px-1.5 py-0.5 rounded">429</code></td>
|
|
590
|
+
<td class="py-3 px-4"><code class="text-xs font-mono">rate_limit_error</code></td>
|
|
591
|
+
<td class="py-3 px-4">Too many requests. Rate limit exceeded.</td>
|
|
592
|
+
<td class="py-3 px-4">Back off and retry. See <a href="#rate-limits" class="text-claude-orange hover:underline">Rate Limits</a>.</td>
|
|
593
|
+
</tr>
|
|
594
|
+
<tr class="border-b border-gray-50">
|
|
595
|
+
<td class="py-3 px-4"><code class="text-xs font-mono bg-red-50 text-red-700 px-1.5 py-0.5 rounded">500</code></td>
|
|
596
|
+
<td class="py-3 px-4"><code class="text-xs font-mono">api_error</code></td>
|
|
597
|
+
<td class="py-3 px-4">Internal server error.</td>
|
|
598
|
+
<td class="py-3 px-4">Retry after a brief delay. Contact support if it persists.</td>
|
|
599
|
+
</tr>
|
|
600
|
+
<tr>
|
|
601
|
+
<td class="py-3 px-4"><code class="text-xs font-mono bg-red-50 text-red-700 px-1.5 py-0.5 rounded">503</code></td>
|
|
602
|
+
<td class="py-3 px-4"><code class="text-xs font-mono">overloaded_error</code></td>
|
|
603
|
+
<td class="py-3 px-4">Upstream provider is temporarily overloaded.</td>
|
|
604
|
+
<td class="py-3 px-4">Wait a moment and retry with exponential backoff.</td>
|
|
605
|
+
</tr>
|
|
606
|
+
</tbody>
|
|
607
|
+
</table>
|
|
608
|
+
</div>
|
|
609
|
+
</div>
|
|
610
|
+
</section>
|
|
611
|
+
|
|
612
|
+
<!-- ============================================================ -->
|
|
613
|
+
<!-- RATE LIMITS -->
|
|
614
|
+
<!-- ============================================================ -->
|
|
615
|
+
<section id="rate-limits" class="mb-16 scroll-mt-24">
|
|
616
|
+
<h2 class="text-2xl font-bold text-claude-dark mb-4">Rate Limits</h2>
|
|
617
|
+
<p class="text-gray-600 mb-6 leading-relaxed">Rate limits vary by plan and are enforced per API key. When you exceed a limit, the API returns a <code class="text-xs font-mono bg-gray-100 px-1.5 py-0.5 rounded">429</code> status code. Upgrade your plan for higher throughput.</p>
|
|
618
|
+
|
|
619
|
+
<!-- Per-plan limits -->
|
|
620
|
+
<h3 class="text-base font-semibold text-claude-dark mb-3">Per-Plan Limits</h3>
|
|
621
|
+
<div class="bg-white rounded-xl border border-gray-100 shadow-sm overflow-hidden mb-8">
|
|
622
|
+
<div class="overflow-x-auto">
|
|
623
|
+
<table class="w-full text-sm">
|
|
624
|
+
<thead>
|
|
625
|
+
<tr class="border-b border-gray-100 bg-gray-50/50">
|
|
626
|
+
<th class="text-left py-3 px-4 font-medium text-gray-500">Plan</th>
|
|
627
|
+
<th class="text-left py-3 px-4 font-medium text-gray-500">Requests / min</th>
|
|
628
|
+
<th class="text-left py-3 px-4 font-medium text-gray-500">Requests / day</th>
|
|
629
|
+
<th class="text-left py-3 px-4 font-medium text-gray-500">Monthly Token Quota</th>
|
|
630
|
+
</tr>
|
|
631
|
+
</thead>
|
|
632
|
+
<tbody class="text-gray-600">
|
|
633
|
+
<tr class="border-b border-gray-50">
|
|
634
|
+
<td class="py-3 px-4 font-medium">Free</td>
|
|
635
|
+
<td class="py-3 px-4">10</td>
|
|
636
|
+
<td class="py-3 px-4">100</td>
|
|
637
|
+
<td class="py-3 px-4">100K</td>
|
|
638
|
+
</tr>
|
|
639
|
+
<tr class="border-b border-gray-50">
|
|
640
|
+
<td class="py-3 px-4 font-medium">Basic</td>
|
|
641
|
+
<td class="py-3 px-4">30</td>
|
|
642
|
+
<td class="py-3 px-4">1,000</td>
|
|
643
|
+
<td class="py-3 px-4">5M</td>
|
|
644
|
+
</tr>
|
|
645
|
+
<tr class="border-b border-gray-50">
|
|
646
|
+
<td class="py-3 px-4 font-medium">Pro</td>
|
|
647
|
+
<td class="py-3 px-4">60</td>
|
|
648
|
+
<td class="py-3 px-4">5,000</td>
|
|
649
|
+
<td class="py-3 px-4">50M</td>
|
|
650
|
+
</tr>
|
|
651
|
+
<tr>
|
|
652
|
+
<td class="py-3 px-4 font-medium">Enterprise</td>
|
|
653
|
+
<td class="py-3 px-4">120</td>
|
|
654
|
+
<td class="py-3 px-4">Unlimited</td>
|
|
655
|
+
<td class="py-3 px-4">500M</td>
|
|
656
|
+
</tr>
|
|
657
|
+
</tbody>
|
|
658
|
+
</table>
|
|
659
|
+
</div>
|
|
660
|
+
</div>
|
|
661
|
+
|
|
662
|
+
<!-- Rate limit headers -->
|
|
663
|
+
<h3 class="text-base font-semibold text-claude-dark mb-3">Rate Limit Headers</h3>
|
|
664
|
+
<p class="text-sm text-gray-600 mb-3">Every API response includes headers to help you track your usage in real time:</p>
|
|
665
|
+
<div class="relative mb-6">
|
|
666
|
+
<pre class="bg-gray-900 text-green-400 rounded-lg p-4 text-sm font-mono overflow-x-auto leading-relaxed"><code>x-ratelimit-limit: 60
|
|
667
|
+
x-ratelimit-remaining: 58
|
|
668
|
+
x-ratelimit-reset: 2026-04-08T12:01:00Z</code></pre>
|
|
669
|
+
<button onclick="copyCode(this)" class="absolute top-2 right-2 px-2 py-1 text-xs text-gray-400 bg-gray-800 rounded hover:text-white transition-colors">Copy</button>
|
|
670
|
+
</div>
|
|
671
|
+
|
|
672
|
+
<div class="bg-white rounded-xl border border-gray-100 p-6 shadow-sm">
|
|
673
|
+
<div class="overflow-x-auto">
|
|
674
|
+
<table class="w-full text-sm">
|
|
675
|
+
<thead>
|
|
676
|
+
<tr class="border-b border-gray-100">
|
|
677
|
+
<th class="text-left py-2 px-2 font-medium text-gray-500">Header</th>
|
|
678
|
+
<th class="text-left py-2 px-2 font-medium text-gray-500">Description</th>
|
|
679
|
+
</tr>
|
|
680
|
+
</thead>
|
|
681
|
+
<tbody class="text-gray-600">
|
|
682
|
+
<tr class="border-b border-gray-50">
|
|
683
|
+
<td class="py-2 px-2"><code class="text-xs font-mono bg-gray-50 px-1.5 py-0.5 rounded">x-ratelimit-limit</code></td>
|
|
684
|
+
<td class="py-2 px-2">Maximum number of requests allowed per minute for your plan.</td>
|
|
685
|
+
</tr>
|
|
686
|
+
<tr class="border-b border-gray-50">
|
|
687
|
+
<td class="py-2 px-2"><code class="text-xs font-mono bg-gray-50 px-1.5 py-0.5 rounded">x-ratelimit-remaining</code></td>
|
|
688
|
+
<td class="py-2 px-2">Number of requests remaining in the current rate-limit window.</td>
|
|
689
|
+
</tr>
|
|
690
|
+
<tr>
|
|
691
|
+
<td class="py-2 px-2"><code class="text-xs font-mono bg-gray-50 px-1.5 py-0.5 rounded">x-ratelimit-reset</code></td>
|
|
692
|
+
<td class="py-2 px-2">ISO 8601 timestamp when the rate-limit window resets.</td>
|
|
693
|
+
</tr>
|
|
694
|
+
</tbody>
|
|
695
|
+
</table>
|
|
696
|
+
</div>
|
|
697
|
+
</div>
|
|
698
|
+
</section>
|
|
699
|
+
|
|
700
|
+
<!-- CTA -->
|
|
701
|
+
<section class="mb-16">
|
|
702
|
+
<div class="bg-gradient-to-r from-claude-orange/10 to-claude-orange/5 rounded-2xl p-8 text-center border border-claude-orange/10">
|
|
703
|
+
<h2 class="text-xl font-bold text-claude-dark mb-2">Ready to get started?</h2>
|
|
704
|
+
<p class="text-gray-600 mb-6">Create a free account and send your first API request in under a minute.</p>
|
|
705
|
+
<div class="flex flex-col sm:flex-row items-center justify-center gap-3">
|
|
706
|
+
<a href="/register" class="inline-flex items-center px-6 py-3 text-sm font-medium text-white bg-claude-orange rounded-xl hover:bg-opacity-90 transition-all shadow-sm hover:shadow">
|
|
707
|
+
Sign Up Free
|
|
708
|
+
<svg class="ml-2 w-4 h-4" fill="none" stroke="currentColor" viewBox="0 0 24 24"><path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M13 7l5 5m0 0l-5 5m5-5H6"/></svg>
|
|
709
|
+
</a>
|
|
710
|
+
<a href="/pricing" class="inline-flex items-center px-6 py-3 text-sm font-medium text-claude-dark bg-white border border-gray-200 rounded-xl hover:border-claude-orange hover:text-claude-orange transition-all">
|
|
711
|
+
View Pricing
|
|
712
|
+
</a>
|
|
713
|
+
</div>
|
|
714
|
+
</div>
|
|
715
|
+
</section>
|
|
716
|
+
|
|
717
|
+
</main>
|
|
718
|
+
</div>
|
|
719
|
+
</div>
|
|
720
|
+
|
|
721
|
+
<!-- Footer -->
|
|
722
|
+
<footer class="border-t border-gray-100 bg-white">
|
|
723
|
+
<div class="max-w-7xl mx-auto px-4 sm:px-6 lg:px-8 py-8">
|
|
724
|
+
<div class="flex flex-col sm:flex-row items-center justify-between gap-4">
|
|
725
|
+
<p class="text-sm text-gray-400">© 2025 LLM API. All rights reserved.</p>
|
|
726
|
+
<div class="flex items-center space-x-6">
|
|
727
|
+
<a href="/docs" class="text-sm text-gray-400 hover:text-claude-orange transition-colors">Docs</a>
|
|
728
|
+
<a href="/pricing" class="text-sm text-gray-400 hover:text-claude-orange transition-colors">Pricing</a>
|
|
729
|
+
</div>
|
|
730
|
+
</div>
|
|
731
|
+
</div>
|
|
732
|
+
</footer>
|
|
733
|
+
|
|
734
|
+
<script>
|
|
735
|
+
// ---- Copy code block ----
|
|
736
|
+
function copyCode(btn) {
|
|
737
|
+
const pre = btn.closest('.relative').querySelector('pre');
|
|
738
|
+
const code = pre.querySelector('code');
|
|
739
|
+
const text = code ? code.textContent : pre.textContent;
|
|
740
|
+
navigator.clipboard.writeText(text).then(function() {
|
|
741
|
+
var orig = btn.textContent;
|
|
742
|
+
btn.textContent = 'Copied!';
|
|
743
|
+
setTimeout(function() { btn.textContent = orig; }, 2000);
|
|
744
|
+
});
|
|
745
|
+
}
|
|
746
|
+
|
|
747
|
+
// ---- OS tab switcher ----
|
|
748
|
+
function switchTab(btn, panelId) {
|
|
749
|
+
// Determine group from sibling tabs
|
|
750
|
+
var tabBar = btn.parentElement;
|
|
751
|
+
var tabs = tabBar.querySelectorAll('.os-tab');
|
|
752
|
+
tabs.forEach(function(t) {
|
|
753
|
+
t.classList.remove('border-claude-orange', 'text-claude-orange');
|
|
754
|
+
t.classList.add('border-transparent', 'text-gray-500');
|
|
755
|
+
});
|
|
756
|
+
btn.classList.remove('border-transparent', 'text-gray-500');
|
|
757
|
+
btn.classList.add('border-claude-orange', 'text-claude-orange');
|
|
758
|
+
|
|
759
|
+
// Hide sibling panels, show target
|
|
760
|
+
var container = tabBar.closest('.flex-1') || tabBar.parentElement.parentElement;
|
|
761
|
+
var panels = container.querySelectorAll('.tab-panel');
|
|
762
|
+
panels.forEach(function(p) { p.classList.add('hidden'); });
|
|
763
|
+
document.getElementById(panelId).classList.remove('hidden');
|
|
764
|
+
}
|
|
765
|
+
|
|
766
|
+
// ---- Sidebar scroll-spy ----
|
|
767
|
+
function updateActiveNav() {
|
|
768
|
+
var sections = document.querySelectorAll('section[id]');
|
|
769
|
+
var links = document.querySelectorAll('.doc-nav-link');
|
|
770
|
+
var current = '';
|
|
771
|
+
|
|
772
|
+
sections.forEach(function(section) {
|
|
773
|
+
var rect = section.getBoundingClientRect();
|
|
774
|
+
if (rect.top <= 120) {
|
|
775
|
+
current = section.id;
|
|
776
|
+
}
|
|
777
|
+
});
|
|
778
|
+
|
|
779
|
+
links.forEach(function(link) {
|
|
780
|
+
var href = link.getAttribute('href').slice(1);
|
|
781
|
+
if (href === current) {
|
|
782
|
+
link.classList.add('text-claude-orange', 'bg-orange-50');
|
|
783
|
+
link.classList.remove('text-gray-600');
|
|
784
|
+
} else {
|
|
785
|
+
link.classList.remove('text-claude-orange', 'bg-orange-50');
|
|
786
|
+
link.classList.add('text-gray-600');
|
|
787
|
+
}
|
|
788
|
+
});
|
|
789
|
+
}
|
|
790
|
+
|
|
791
|
+
window.addEventListener('scroll', updateActiveNav);
|
|
792
|
+
updateActiveNav();
|
|
793
|
+
|
|
794
|
+
// Close mobile TOC when clicking outside
|
|
795
|
+
document.addEventListener('click', function(e) {
|
|
796
|
+
var toc = document.getElementById('mobileToc');
|
|
797
|
+
if (toc && !toc.classList.contains('hidden')) {
|
|
798
|
+
var fab = toc.parentElement;
|
|
799
|
+
if (!fab.contains(e.target)) {
|
|
800
|
+
toc.classList.add('hidden');
|
|
801
|
+
}
|
|
802
|
+
}
|
|
803
|
+
});
|
|
804
|
+
</script>
|
|
805
|
+
|
|
806
|
+
</body>
|
|
807
|
+
</html>
|