Skip to content
KendorDocs

Coding challenges where the candidate's app calls AI models

For challenge authors ·

Let a candidate's own code call Claude and OpenAI models on your keys, with its own token budget, apart from the AI assistants in the terminal.

Some challenges are about building with AI: a RAG endpoint, an agent, a classifier that calls a model. For those, the candidate's own code needs to reach a model. Kendor lets it do that on your organization's Anthropic or OpenAI key, through the sandbox's AI gateway, without the key ever entering the sandbox.

Switch it on

In the screen builder, under What candidates get, turn on App can call AI models. Each candidate gets an app token budget, 1 million tokens unless you change it. It is counted apart from the AI assistants' budget, and both count toward your organization's monthly limit.

App calls run on the Anthropic or OpenAI key in Integrations, so add one first. The builder warns you when none is set.

A project can say that its code calls models, so screens built from it switch app calls on when you add the challenge:

ai:
  app: true

Two templates show the whole setup: FastAPI + pgvector RAG (Python) and TypeScript + pgvector RAG. Both answer questions about a small help centre with OpenAI embeddings, pgvector and Claude, and their tests use fake models, so they pass without a key.

What the code uses

Every sandbox already sets the variables the official SDKs read, so the code needs no setup:

Variable Read by
ANTHROPIC_BASE_URL, ANTHROPIC_API_KEY, ANTHROPIC_AUTH_TOKEN Anthropic SDKs, LangChain, LlamaIndex
OPENAI_BASE_URL, OPENAI_API_KEY OpenAI SDKs and most libraries built on them

The keys are tokens for this sandbox only, not your organization's keys. The gateway checks the budget and swaps in the real key on the way out.

from anthropic import Anthropic
from openai import OpenAI

claude = Anthropic()
reply = claude.messages.create(
    model="claude-haiku-5-5",
    max_tokens=300,
    messages=[{"role": "user", "content": "Summarise this ticket."}],
)

openai = OpenAI()
vectors = openai.embeddings.create(model="text-embedding-3-small", input=["first chunk"])
import Anthropic from '@anthropic-ai/sdk';
import OpenAI from 'openai';

const claude = new Anthropic();
const reply = await claude.messages.create({
    model: 'claude-haiku-5-5',
    max_tokens: 300,
    messages: [{ role: 'user', content: 'Summarise this ticket.' }],
});

const openai = new OpenAI();
const vectors = await openai.embeddings.create({
    model: 'text-embedding-3-small',
    input: ['first chunk'],
});

What gets through

The gateway forwards model calls only: Anthropic Messages, and OpenAI Responses, Chat Completions and Embeddings, plus each vendor's model list. Everything else on the vendor API, such as files or batches, returns 404. A vendor you have no key for returns 403.

Python packages already installed

Python sandboxes come with numpy, pandas, scikit-learn, scipy and PyTorch (the CPU build) already installed, so import torch works without a download. If the project pins another version in requirements.txt, pip install puts that version in the workspace and it wins.

A virtual environment made with python -m venv doesn't see the preinstalled packages. Create it with --system-site-packages to keep them. Models downloaded through Hugging Face or PyTorch go to a cache outside the workspace, so they aren't saved with the candidate's code.

Budgets and what reviewers see

The candidate sees a small ring in the editor header that fills toward the app budget. When the budget is used up, further calls return 403 with a clear message. Reviewers see the app's token count next to the attempt, as "App 240k / 1M tokens".

Kendor keeps only the token counts. The requests and replies of app calls are never stored, and the candidate is told before they start that their app can call models on your account.

With the AI assistants on too

The two switches are independent: you can let the app call models with no assistant in the terminal, or turn both on. When an assistant starts a program, for example Claude Code running npm start, that program's calls count toward the assistant's budget rather than the app's.

There is one exception. If the assistants run on the candidate's own account, a program the assistant starts can't call models: the assistant runs without the variables above, and so does everything it starts. The candidate should start the app from the Processes view or their own terminal tab instead.

Was this article helpful?