Replit workspaces support secrets — encrypted environment variables that are available to your code at runtime but never exposed in the editor. Store your OPENDUNES_API_KEY as a secret and you can call OpenDunes from any language Replit supports.
- Open your Replit workspace.
- Click the Secrets tab in the left sidebar (the padlock icon).
- Add a new secret:
- Key:
OPENDUNES_API_KEY
- Value: your key from your dashboard
- Click Add secret.
The secret is now available as an environment variable to all runs in that workspace.
Create a new Python Repl and install the OpenAI SDK:
Then:
import os
from openai import OpenAI
client = OpenAI(
base_url="https://opendunes.com/api/v1",
api_key=os.environ["OPENDUNES_API_KEY"],
)
resp = client.chat.completions.create(
model="anthropic/claude-sonnet-5",
messages=[{"role": "user", "content": "What is the capital of Algeria?"}],
)
print(resp.choices[0].message.content)
Create a new Node.js Repl and install the OpenAI SDK:
Then:
import OpenAI from "openai";
const client = new OpenAI({
baseURL: "https://opendunes.com/api/v1",
apiKey: process.env.OPENDUNES_API_KEY,
});
const resp = await client.chat.completions.create({
model: "google/gemini-2.5-pro",
messages: [{ role: "user", content: "What is the capital of Algeria?" }],
});
console.log(resp.choices[0].message.content);
Streaming works the same way as in any other environment — set stream: true and iterate the response:
stream = client.chat.completions.create(
model="meta-llama/llama-4-maverick",
messages=[{"role": "user", "content": "Write a short poem about the Hoggar mountains."}],
stream=True,
)
for chunk in stream:
delta = chunk.choices[0].delta.content
if delta:
print(delta, end="", flush=True)
- Replit's free plan may have outbound network limits. If a request hangs, check your workspace's egress settings.
- Secrets are per-workspace. If you fork a Repl, the forked workspace does not inherit secrets — add your key again.
- Browse available models at /models or call
GET /api/models from within your Repl.