AI

Switch Your OpenAI SDK App to Clean Energy in Two Lines

Move an app built on the OpenAI SDK to the Viro API by changing the base URL and model name. Python, JavaScript and curl examples, plus streaming, tool calling and embeddings, on models powered by renewable energy.

If your app uses the OpenAI SDK, you can move it onto models powered by renewable energy without rewriting anything. The Viro API is OpenAI-compatible: change the base URL and the model name, and the rest of your code stays the same.

The short version

client = OpenAI(
    api_key=os.environ["VIRO_API_KEY"],
    base_url="https://api.viro.app/v1",   # line 1
)
response = client.chat.completions.create(
    model="viro/clean",                    # line 2
    messages=[{"role": "user", "content": "Hello from Viro"}],
)

That’s it. Get a key at console.viro.app; new accounts get free sandbox credit, no card needed.

Python

import os
from openai import OpenAI

client = OpenAI(
    api_key=os.environ["VIRO_API_KEY"],
    base_url="https://api.viro.app/v1",
)

response = client.chat.completions.create(
    model="viro/kimi-k2.5",
    messages=[{"role": "user", "content": "Explain recursion in one sentence."}],
)
print(response.choices[0].message.content)

JavaScript / TypeScript

import OpenAI from "openai";

const client = new OpenAI({
  apiKey: process.env.VIRO_API_KEY,
  baseURL: "https://api.viro.app/v1",
});

const response = await client.chat.completions.create({
  model: "viro/kimi-k2.5",
  messages: [{ role: "user", content: "Explain recursion in one sentence." }],
});
console.log(response.choices[0].message.content);

curl

curl https://api.viro.app/v1/chat/completions \
  -H "Authorization: Bearer $VIRO_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "model": "viro/clean",
    "messages": [{"role": "user", "content": "Hello from Viro"}]
  }'

Pick a model

Every model has a slug with its provider in front. Some good starting points:

Slug Energy Price per 1M tokens (in / out)
viro/clean 100% renewable (router) Varies by model
viro/deepseek-v4.1-flash 100% renewable $0.36 / $1.80
viro/kimi-k2.5 100% renewable $0.68 / $3.30
viro/kimi-k2.7-code 100% renewable $1.56 / $6.24
openai/gpt-5.6-terra Energy matched $3.00 / $18.00
anthropic/claude-sonnet-5 Energy matched $3.00 / $15.00

Prices from the Viro API catalog in November 2026. List everything available with GET https://api.viro.app/v1/models, or browse the model catalog.

Routers pick a model for you per request:

  • viro/clean: the best eligible model on renewable-verified infrastructure.
  • viro/optimized: the most efficient model that meets the quality bar.
  • viro/frontier: the strongest available model.

What else works

The Viro API supports the parts of the OpenAI API most apps rely on, on supported models:

  • Streaming: pass stream=True (Python) or stream: true (JS) as usual.
  • Tool / function calling: same tools and tool_calls shapes.
  • Structured outputs: JSON responses work the same way.
  • Embeddings: use an embedding model like viro/qwen3-embedding-8b with client.embeddings.create.

Tool-calling reliability varies by model, so test your agent flows on the model you pick.

Keep your key out of your code

Store the key in an environment variable or your platform’s secrets manager:

export VIRO_API_KEY="viro_sk_..."

Why switch?

  • Clean by default: open models run in data centers powered by 100% renewable energy, in Iceland, Norway, Finland and Ireland.
  • Frontier models, labelled honestly: GPT, Claude, Gemini and Grok through the same key, with their energy matched with renewables.
  • Zero data retention for Viro-hosted models.
  • Often cheaper: many clean models cost a fraction of frontier prices.

New to the idea? Read what is a green AI API. Building with a coding agent? See the best clean-energy models for coding and our OpenCode setup guide.

Get a free Viro API key

Frequently asked questions

Is the Viro API compatible with the OpenAI SDK?

Yes. Point the official OpenAI SDK at https://api.viro.app/v1 with a Viro API key. Chat completions, streaming, tool calling and structured outputs work the same way on supported models.

What do I need to change in my code?

The base URL and the API key when you create the client, and the model name in your requests, for example viro/kimi-k2.5 or the viro/clean router. Everything else stays the same.

Can I still use GPT models?

Yes. Frontier models from OpenAI, Anthropic, Google and xAI are available through the same endpoint, for example openai/gpt-5.6-terra, with their energy matched with renewables.

Does Viro store my prompts?

Viro is designed around zero data retention: prompt and response content isn't stored after processing. Frontier models are also covered by their provider's own data policy.

How much does it cost to try?

New accounts get free sandbox credit with no card required. After that, pricing is per token and varies by model.

Sources

  1. Viro API, Viro
  2. Viro API model catalog, Viro

Cover photo by Mohammad Rahmani on Unsplash

Chat with AI that funds clean energy

Viro AI is free on web, iPhone, Android, Mac and Windows.

Try Viro AI