Search
Code14
} const body = await req.json(); const apiKey = Deno.env.get("ANTHROPIC_API_KEY"); console.log("API key exists:", !!apiKey); console.log("API key starts with:", apiKey?.slice(0, 7)); const response = await fetch("https://api.anthropic.com/v1/messages", { method: "POST", headers: { "Content-Type": "application/json", "x-api-key": apiKey, "anthropic-version": "2023-06-01", }, body: JSON.stringify(body), }); const data = await response.json(); console.log("Anthropic status:", response.status); console.log("Response:", JSON.stringify(data).slice(0, 200)); return new Response(JSON.stringify(data), { ["aiforswes", ["AI"], "https://www.aiforswes.com/feed"], ["openaiNews", ["AI"], "https://openai.com/news/rss.xml"], ["anthropicNews", ["AI"], "https://raw.githubusercontent.com/Olshansk/rss-feeds/main/feeds/feed_anthropic_news.xml"], ["aiNews", ["AI"], "https://news.smol.ai/rss.xml"], ["anthropicEngineering", ["AI"], "https://raw.githubusercontent.com/Olshansk/rss-feeds/main/feeds/feed_anthropic_engineering.xml"], ["anthropicResearch", ["AI"], "https://raw.githubusercontent.com/Olshansk/rss-feeds/main/feeds/feed_anthropic_research.xml"], ["languageModels", ["AI"], "https://newsletter.languagemodels.co/feed"], ["gregBrockman", ["AI"], "https://blog.gregbrockman.com/feed"], } = body; const ANTHROPIC_API_KEY = Deno.env.get("ANTHROPIC_API_KEY"); console.log( try { const response = await fetch("https://api.anthropic.com/v1/messages", { method: "POST", headers: { "Content-Type": "application/json", "x-api-key": ANTHROPIC_API_KEY, "anthropic-version": "2023-06-01", }, body: JSON.stringify({ const targetCompany = idealClient || prospectCompany; const ANTHROPIC_API_KEY = Deno.env.get("ANTHROPIC_API_KEY"); console.log("Discovery v3:", { try { const response = await fetch("https://api.anthropic.com/v1/messages", { method: "POST", headers: { "Content-Type": "application/json", "x-api-key": ANTHROPIC_API_KEY, "anthropic-version": "2023-06-01", }, body: JSON.stringify({ try { const fallbackResponse = await fetch( "https://api.anthropic.com/v1/messages", { method: "POST", headers: { "Content-Type": "application/json", "x-api-key": ANTHROPIC_API_KEY, "anthropic-version": "2023-06-01", }, body: JSON.stringify({ const targetCompany = idealClient || prospectCompany; const ANTHROPIC_API_KEY = Deno.env.get("ANTHROPIC_API_KEY"); console.log("Discovery v3:", { try { const response = await fetch("https://api.anthropic.com/v1/messages", { method: "POST", headers: { "Content-Type": "application/json", "x-api-key": ANTHROPIC_API_KEY, "anthropic-version": "2023-06-01", }, body: JSON.stringify({ try { const fallbackResponse = await fetch( "https://api.anthropic.com/v1/messages", { method: "POST", headers: { "Content-Type": "application/json", "x-api-key": ANTHROPIC_API_KEY, "anthropic-version": "2023-06-01", }, body: JSON.stringify({ } = body; const ANTHROPIC_API_KEY = Deno.env.get("ANTHROPIC_API_KEY"); console.log( try { const response = await fetch("https://api.anthropic.com/v1/messages", { method: "POST", headers: { "Content-Type": "application/json", "x-api-key": ANTHROPIC_API_KEY, "anthropic-version": "2023-06-01", }, body: JSON.stringify({// Updated: 2026-02-06import Anthropic from "npm:@anthropic-ai/sdk";import { PDFDocument, rgb, StandardFonts } from "npm:pdf-lib";// CONFIGURATION clientData: ClientData,): Promise<ProcessedData> { const anthropic = new Anthropic({ apiKey: Deno.env.get("ANTHROPIC_API_KEY"), });}`; const response = await anthropic.messages.create({ model: "claude-sonnet-4-20250514", max_tokens: 6000, } const res = await fetch("https://api.anthropic.com/v1/messages", { method: "POST", headers: { "Content-Type": "application/json", "x-api-key": k, "anthropic-version": "2023-06-01", }, body: JSON.stringify({import { Hono } from "https://esm.sh/hono@3.11.7";import { anthropic } from "https://esm.sh/@ai-sdk/anthropic@1.2.12";import { generateText } from "https://esm.sh/ai@4.3.15";import { createRecipe } from "../database/queries.ts"; try { const result = await generateText({ model: anthropic("claude-3-5-haiku-latest"), prompt: `Extract the recipe from this page content and return ONLY valid JSON matching this schema:{## Environment Variable- **ANTHROPIC_API_KEY** - Available on Val Town and locally## Files to Create```typescriptimport { Hono } from "https://esm.sh/hono@4.4.2";import { anthropic } from "https://esm.sh/@ai-sdk/anthropic";import { generateText } from "https://esm.sh/ai";import { createRecipe } from "../database/queries.ts";// 4. Call Claude API for extraction using Vercel AI SDKconst { text } = await generateText({model: anthropic("claude-3-5-haiku-latest"),prompt: `Extract the recipe from this page content and return ONLY valid JSON matching this schema:{## Vercel AI SDK Usage (Recommended by Val Town)- Package: `@ai-sdk/anthropic` with `ai` core- API key auto-read from `ANTHROPIC_API_KEY` env var- Model: `claude-3-5-haiku-latest` (fast and efficient for extraction)- Function: `generateText()` for simple text generation## Technical Notes- Use `https://esm.sh/@ai-sdk/anthropic` and `https://esm.sh/ai` for imports- Claude 3.5 Haiku is fast and efficient for extraction tasks- 15k char limit prevents token overflow## References- [Val Town @ai-sdk/anthropic examples](https://www.val.town/examples/packages/@ai-sdk%2Fanthropic)- [AI SDK Anthropic Provider docs](https://ai-sdk.dev/providers/ai-sdk-providers/anthropic)DEPENDS ON- Strips HTML to plain text (removes script/style tags, then all HTML tags)- Limits content to 15k characters- Calls Claude 3.5 Haiku via the Vercel AI SDK (`@ai-sdk/anthropic` + `ai`)- Parses the AI response as JSON- Handles the "No recipe found" error case
Vals
No vals found
Users
No users found
Docs
No docs found