Loading skill
Install any skill in seconds. Free to start, no credit card required.
Get Started Free →Covers LLM integration patterns in TypeScript: API calls, streaming, function calling, RAG pipelines, and cost optimization.
59% 100%+41 ptsof test cases passed
Passed 22 of 22 test cases with the skill, and 13 of 22 without it.
3 of 3 safety checks passed
Not used yet
import Anthropic from "@anthropic-ai/sdk";
const client = new Anthropic();
async function generateResponse(
systemPrompt: string,
userMessage: string,
options?: { maxTokens?: number; temperature?: number }
): Promise<string> {
const response = await client.messages.create({
model: "claude-sonnet-4-20250514",
max_tokens: options?.maxTokens ?? 1024,
temperature: options?.temperature ?? 0,
system: systemPrompt,
messages: [{ role: "user", content: userMessage }],
});
const textBlock = response.content.find(block => block.type === "text");
return textBlock?.text ?? "";
}
async function streamResponse(
messages: Array<{ role: "user" | "assistant"; content: string }>,
onChunk: (text: string) => void
): Promise<string> {
const stream = client.messages.stream({
model: "claude-sonnet-4-20250514",
max_tokens: 4096,
messages,
});
Skills that do similar work, with their benchmark result.
Next to this one in the catalogue, plus more from the same author.