import Anthropic from '@anthropic-ai/sdk';
const client = new Anthropic({ apiKey: process.env.ANTHROPIC_API_KEY });
const message = await client.messages.create({
model: 'claude-opus-4-7',
max_tokens: 1024,
messages: [{ role: 'user', content: 'Summarize quantum computing in 3 bullet points.' }],
});
console.log(message.content[0].text);import { GoogleGenerativeAI } from '@google/generative-ai';
const genAI = new GoogleGenerativeAI(process.env.GEMINI_API_KEY);
const model = genAI.getGenerativeModel({ model: 'gemini-1.5-flash' });
const result = await model.generateContent('Explain machine learning in one paragraph.');
console.log(result.response.text());import { InferenceClient } from '@huggingface/inference';
const client = new InferenceClient(process.env.HF_TOKEN);
const result = await client.textClassification({
model: 'distilbert-base-uncased-finetuned-sst-2-english',
inputs: 'I love building things with AI!',
});
console.log(result[0]); // { label: 'POSITIVE', score: 0.99 }import OpenAI from 'openai';
const openai = new OpenAI({ apiKey: process.env.OPENAI_API_KEY });
const completion = await openai.chat.completions.create({
model: 'gpt-4o',
messages: [{ role: 'user', content: 'Explain quantum computing in 2 sentences.' }],
});
console.log(completion.choices[0].message.content);import Replicate from 'replicate';
const replicate = new Replicate({ auth: process.env.REPLICATE_API_TOKEN });
const output = await replicate.run(
'black-forest-labs/flux-schnell',
{ input: { prompt: 'A futuristic city at sunset, photorealistic' } }
);
console.log('Generated image URL:', output[0]);const res = await fetch(
'https://api.stability.ai/v1/generation/stable-diffusion-xl-1024-v1-0/text-to-image',
{
method: 'POST',
headers: {
'Content-Type': 'application/json',
Accept: 'application/json',
Authorization: `Bearer ${process.env.STABILITY_API_KEY}`,
},
body: JSON.stringify({
text_prompts: [{ text: 'A serene mountain lake at golden hour' }],
cfg_scale: 7,
height: 1024,
width: 1024,
samples: 1,
}),
}
);
const { artifacts } = await res.json();
console.log('Image base64 length:', artifacts[0].base64.length);