Hello World
Let’s write a simple program that uses AI to translate “Hello World” into multiple languages.
Create Your First Program
Section titled “Create Your First Program”Create a file called hello.vibe:
model translator = { name: "claude-haiku-4-5-20251001", provider: "anthropic", apiKey: env("ANTHROPIC_API_KEY")}
const languages: text[] = do "List the major human languages"
for language in languages { const translated = do "Translate 'Hello World' into {language}" print(translated)}Run It
Section titled “Run It”vibe hello.vibeYou’ll see “Hello World” translated into various languages!
Understanding the Code
Section titled “Understanding the Code”Let’s break down what’s happening:
Model Declaration
Section titled “Model Declaration”model translator = { name: "claude-haiku-4-5-20251001", provider: "anthropic", apiKey: env("ANTHROPIC_API_KEY")}This configures which AI model to use. The env() function reads from your environment variables.
AI Expression with do
Section titled “AI Expression with do”const languages: text[] = do "List the major human languages"The do keyword sends a prompt to the AI and returns the result. Here we’re asking for a list of languages and typing it as text[] (array of strings).
Loop with Context
Section titled “Loop with Context”for language in languages { const translated = do "Translate 'Hello World' into {language}" print(translated)}The {language} syntax creates a reference that the AI can see in context. The AI knows what language contains and uses it to complete the task. See AI Prompts for more on interpolation.
Try Different Providers
Section titled “Try Different Providers”Switch to OpenAI by changing the model:
model translator = { name: "gpt-5.2", provider: "openai", apiKey: env("OPENAI_API_KEY")}Or Google:
model translator = { name: "gemini-3-flash", provider: "google", apiKey: env("GOOGLE_API_KEY")}Next Steps
Section titled “Next Steps”Now that you’ve written your first program, learn about:
- Basic Syntax - Variables, types, and operators
- AI Prompts - The
doandvibekeywords in depth - Models - Configuring AI providers