Back to UI-TARS-desktop

LLM Examples

multimodal/tarko/llm/examples/README.md

0.3.03.0 KB
Original Source

LLM Examples

This guide provides an overview of the developer links and call methods for common models.

Config API Key

bash
export OPENAI_API_KEY=x
export ANTHROPIC_API_KEY=y

LLM Providers

OpenAI

TypeURL
GET API KEYShttps://platform.openai.com/api-keys
API Documentationhttps://platform.openai.com/docs/api-reference/introduction
OpenAPI Specificationhttps://github.com/openai/openai-openapi
Githubhttps://github.com/openai/openai-node
NPMhttps://www.npmjs.com/openai-node
ts
import OpenAI from 'openai';

const client = new OpenAI({
  apiKey: process.env['OPENAI_API_KEY'], // This is the default and can be omitted
});

const response = await client.responses.create({
  model: 'gpt-4o',
  instructions: 'You are a coding assistant that talks like a pirate',
  input: 'Are semicolons optional in JavaScript?',
});

console.log(response.output_text);

Anthropic

Gemini

TypeURL
GET API KEYShttps://aistudio.google.com/apikey
API Documentationhttps://ai.google.dev/gemini-api/docs
NPMhttps://www.npmjs.com/package/@google/genai
Modelshttps://ai.google.dev/gemini-api/docs/models
Quotashttps://console.cloud.google.com/apis/api/generativelanguage.googleapis.com/quotas
ts
import { GoogleGenAI } from '@google/genai';

const ai = new GoogleGenAI({ apiKey: process.env.GEMINI_API_KEY });

async function main() {
  const response = await ai.models.generateContent({
    model: 'gemini-2.0-flash',
    contents: 'Explain how AI works',
  });
  console.log(response.text);
}

await main();

[!WARNING] What's the difference between these two packages?

OpenAI Compatibility

TypeURL
Geminihttps://ai.google.dev/gemini-api/docs/openai
Anthropichttps://docs.anthropic.com/en/api/openai-sdk
Ollamahttps://github.com/ollama/ollama/blob/main/docs/openai.md
LM Studiohttps://lmstudio.ai/docs/app/api/endpoints/openai