TypeScript 97.4%
SQL 1%
JavaScript 0.9%
CSS 0.6%
1// Secondary surfaces: Anthropic-compatible /anthropic/v1/messages, /responses (streaming), /beta prefix completion, /beta FIM.2import { raw, rawSSE, save, KEY } from "./lib.ts";34const out: Record<string, unknown> = {};5// Anthropic format6{7 const res = await fetch("https://api.deepseek.com/anthropic/v1/messages", { method: "POST", headers: { "Content-Type": "application/json", "x-api-key": KEY, "anthropic-version": "2023-06-01" }, body: JSON.stringify({ model: "deepseek-v4-flash", max_tokens: 100, thinking: { type: "enabled", budget_tokens: 1024 }, messages: [{ role: "user", content: "Say hi in 3 words." }] }) });8 const t = await res.text(); let b: unknown = t; try { b = JSON.parse(t); } catch {}9 out.anthropic_messages = { status: res.status, body: b };10 console.log("anthropic /v1/messages →", res.status, JSON.stringify(b).slice(0, 500));11 const res2 = await fetch("https://api.deepseek.com/anthropic/v1/messages", { method: "POST", headers: { "Content-Type": "application/json", "x-api-key": KEY, "anthropic-version": "2023-06-01" }, body: JSON.stringify({ model: "claude-sonnet-4-5", max_tokens: 50, messages: [{ role: "user", content: "Which model are you? 5 words." }] }) });12 const t2 = await res2.text(); let b2: unknown = t2; try { b2 = JSON.parse(t2); } catch {}13 out.anthropic_claude_alias = { status: res2.status, body: b2 };14 console.log("anthropic claude alias →", res2.status, JSON.stringify(b2).slice(0, 300));15}16// Responses API streaming17{18 const s = await rawSSE("/responses", { model: "deepseek-v4-flash", input: "Say hello in 3 words.", max_output_tokens: 100, reasoning: { effort: "low" }, stream: true });19 const types = s.events.filter((e) => e !== "[DONE]").map((e: any) => e.type);20 out.responses_stream = { status: s.status, error: (s as any).error, eventTypes: [...new Set(types)], count: s.events.length, last: s.events.slice(-2) };21 console.log("responses stream →", s.status, [...new Set(types)].join(","), JSON.stringify(s.events.slice(-2)).slice(0, 600));22 const r = await raw("/responses", { method: "POST", body: JSON.stringify({ model: "deepseek-v4-flash", input: "Say hello in 3 words.", max_output_tokens: 100, reasoning: { effort: "none" } }) });23 out.responses_nonstream_effort_none = { status: r.status, body: r.body };24 console.log("responses effort=none →", r.status, JSON.stringify(r.body).slice(0, 500));25}26// Beta: chat prefix completion27{28 const r = await raw("/chat/completions", { method: "POST", base: "https://api.deepseek.com/beta", body: JSON.stringify({ model: "deepseek-v4-flash", thinking: { type: "disabled" }, max_tokens: 60, stop: ["```"], messages: [{ role: "user", content: "Write a python one-liner that prints hello" }, { role: "assistant", content: "```python\n", prefix: true }] }) });29 out.beta_prefix = { status: r.status, body: r.body };30 console.log("beta prefix →", r.status, JSON.stringify((r.body as any).choices?.[0]?.message ?? r.body).slice(0, 300));31 const r2 = await raw("/chat/completions", { method: "POST", body: JSON.stringify({ model: "deepseek-v4-flash", thinking: { type: "disabled" }, max_tokens: 60, messages: [{ role: "user", content: "Write a python one-liner that prints hello" }, { role: "assistant", content: "```python\n", prefix: true }] }) });32 out.prefix_without_beta = { status: r2.status, body: r2.body };33 console.log("prefix without /beta →", r2.status, JSON.stringify(r2.body).slice(0, 300));34}35// Beta FIM36{37 const r = await raw("/completions", { method: "POST", base: "https://api.deepseek.com/beta", body: JSON.stringify({ model: "deepseek-v4-flash", prompt: "def fib(a):", suffix: " return fib(a-1) + fib(a-2)", max_tokens: 40 }) });38 out.beta_fim_flash = { status: r.status, body: r.body };39 console.log("beta FIM flash →", r.status, JSON.stringify(r.body).slice(0, 300));40 const r2 = await raw("/completions", { method: "POST", base: "https://api.deepseek.com/beta", body: JSON.stringify({ model: "deepseek-v4-pro", prompt: "def fib(a):", suffix: " return fib(a-1) + fib(a-2)", max_tokens: 40 }) });41 out.beta_fim_pro = { status: r2.status, body: r2.body };42 console.log("beta FIM pro →", r2.status, JSON.stringify(r2.body).slice(0, 300));43}44save("08-other-apis.json", out);45