AI as an API

Typed answers with a confidence, not prose. It has a name now.

·

July 2024, on my Telegram channel:

23 July 2024
💡AI as an API to accelerate development. Instead of using AI to help you code an API: [USER NEED] -> AI as API -> Validation -> Refine for cost/quality.
def complex_task():
    """
    Input: Complex JSON data
    Instructions: Analyze and produce structured output
    Output: {
        "result": "Predicted outcome",
        "confidence": 0.95
    }
    """
Traditionally you'd add a pass for a function like this or you'd just give up while implementing, now you can let AI be a blackbox that produces the output that you need validated with something like pydantic, using instructor. Very specific use-cases, but I'm sure everyone misses them still. (Natural Language Coding)
59 viewsedited00:27

Don't write the function. Describe it. Let the model be the body, validate what comes back, refine for cost and quality.

The part that mattered was the last line of the output: "confidence": 0.95. An answer your code can act on, plus how much to trust it.

2025

In June I wrote it down properly: Intention Is All You Need. A function defined by its purpose, not its body.

python
class SentimentResult(BaseModel):
    sentiment: Literal["positive", "negative", "neutral"]
    confidence: float = Field(ge=0.0, le=1.0)

@telos
def analyze_sentiment(text: str) -> SentimentResult:
    """Analyze the sentiment of a text string."""
    pass

analyze_sentiment("This is amazing! I love it!")  # positive (0.98)
# day 1:  an LLM answers it,         847ms, $0.01 a call
# day 30: code it synthesized itself, 0.001ms

Typed in, typed out, and a confidence in what it returns. It works from the first call because an LLM answers it, and with use it writes the code that replaces the LLM.

Self-improving programs defined by purpose that magically work and evolve with use

2 stars0 forksApache-2.0Updated Jun 13, 2025

Three weeks later Vercel opened an issue for an AI CLI. Guillermo asked for files, model switching and pipes:

rauchg commented on
  • Files support – make it really easy to attach a bunch of files, upload transparently
  • Easy model switching - e.g.: -m to alternate between models
  • Unix-y - make it easy to pipe, consume stdin, etc. e.g.: echo 'what is life?' | npx ai
❤️, 1 reaction

I asked for one more thing: a schema, so the output is data you compose, not text you read. AI as an API blackbox, from the shell.

  • Structured output, so it can be used as code, composable.

Usage

$ curl -s https://acme.com/pricing | \
  npx ai "extract pricing tiers" --schema '{
    "tiers": [{
      "name": "string",
      "price": "number",
      "bandwidth_gb": "number",
      "team_members": "number"
    }]
  }'

Output:

{
  "tiers": [
    {"name": "Starter", "price": 0, "bandwidth_gb": 50, "team_members": 1},
    {"name": "Growth", "price": 29, "bandwidth_gb": 500, "team_members": 5},
    {"name": "Scale", "price": 99, "bandwidth_gb": 2000, "team_members": 20},
    {"name": "Enterprise", "price": -1, "bandwidth_gb": -1, "team_members": -1}
  ]
}

Advanced usage – solving harder problems with AI as an API blackbox

Ex: Installing the latest version of a github release is trickier than it may seem, but it could become something like:

#!/bin/bash
# install-latest.sh - Install any GitHub CLI tool with one command

REPO=$1  # e.g., "junegunn/fzf"

# Get latest release data
curl -s "https://api.github.com/repos/$REPO/releases/latest" | \
  npx ai "find download URL for $(uname -s) $(uname -m)" --schema '{
    "download_url": "string",
    "binary_name": "string",
    "extract_command": "string"
  }' > release.json

# Extract the info
URL=$(jq -r .download_url release.json)
BINARY=$(jq -r .binary_name release.json)
EXTRACT=$(jq -r .extract_command release.json)

# Download and install
curl -L "$URL" -o /tmp/download
eval "$EXTRACT” # 🤠
chmod +x "$BINARY"
sudo mv "$BINARY" /usr/local/bin/

echo "✓ Installed $BINARY”

Usage

# Install fzf (handles .tar.gz)
$ ./install-latest.sh junegunn/fzf
✓ Installed fzf

# Install ripgrep (handles different naming: rg)
$ ./install-latest.sh BurntSushi/ripgrep  
✓ Installed rg
Read the rest on GitHub

2026

Two weeks ago it got a name. Decision models.

TypeSafe shipped Jev, a model that doesn't write. State in, typed questions in, probabilities out. A yes/no with how likely it is. A choice with a distribution over the options. A score on a rubric. Nothing to parse, nothing to hallucinate.

Two days later Vercel's ai-cli had it:

bash
cat ticket.txt | ai decide \
  --boolean "refund=Refund requested?" \
  --choice "team=Which team?" \
  --choices "team=billing,support"

It shipped as ai evaluate. Two weeks later they renamed it ai decide. The name caught up with what it does.

The first cut was even closer to the 2024 post: git log | ai filter "describes a concurrency fix", ai rank, ai pick. Records in, records out, decided by meaning.

On Tuesday OpenAI announced a Decisions API at DevDay. Same shape: context in, predefined answers out, with a confidence.

What I keep saying

The model is not the product. The model is a function call. The interesting part was never the prose, it was the typed answer and the number next to it, because that number is what lets code decide when to trust the answer and when to hand it to a person.

Two years from a Telegram post to a product category. The idea was the easy part. TypeSafe did the hard one: a model whose 0.95 actually means 95%.

One layer

A decision model is one layer, not the whole thing.

Feelings are cognition metadata.

·
Sign in to comment

That confidence is the model's feeling about its own answer. A gut call, and how sure the gut is. Sure enough, act. Not sure, think slower, or ask someone.

So I see the model as composable. A hybrid. Fast processes and slow ones, routed by that feeling.

Mixture of Experts already has the shape: a router picks which part of the model handles each token. The name says experts, as in what they know. I think the split that matters is by how they think. Deciding, reasoning, writing, remembering. Different processes, one model, the metadata doing the routing.

Telos already has the loop. A function starts slow, an LLM reasoning out every answer in 847ms, and use turns it into code that answers the same in 0.001ms. System 2 becoming System 1, the way a skill does in a person. A decision model is System 1 out of the box. Telos is how System 2 gets there.

Comments