---
title: "AI providers"
description: "Call Claude from an app without an API key, through the app's wervt identity."
canonical_url: "https://docs.lightdrop.cloud/guides/ai-providers"
---
# AI providers

> Call Claude from an app without an API key, through the app's wervt identity.

An API key in an app's env never expires and works from anywhere it leaks to. Instead, an app
on wervt can prove who it is: wervt is an OpenID Connect issuer (`https://id.lightdrop.cloud`) and
signs short-lived tokens that say "I am the app `todos`". Anthropic trusts that issuer through
[Workload Identity Federation](https://platform.claude.com/docs/en/manage-claude/workload-identity-federation)
and trades such a token for an Anthropic token that lasts minutes. The app's env holds only IDs.

## Set it up

1. Turn on the app's identity (owners only; a deploy token can't) and note its subject:```bash
wervt identity enable todos
# issuer:    https://id.lightdrop.cloud
# subject:   wervt:app:todos:3f9c2a71e0b4d815
# audiences: https://api.anthropic.com
```
2. In the [Claude Console](https://platform.claude.com), under workload identity federation:
  - add an issuer `https://id.lightdrop.cloud` with JWKS from discovery,
  - create a service account for the app,
  - create a rule for that issuer and service account that matches the **exact subject**,
  the audience `https://api.anthropic.com` and the claim `wervt_env` = `production`.
3. Put the IDs from the Console into the app's env. None of them is a secret:```bash
wervt env todos \
  --set ANTHROPIC_FEDERATION_RULE_ID=fdrl_… \
  --set ANTHROPIC_ORGANIZATION_ID=… \
  --set ANTHROPIC_SERVICE_ACCOUNT_ID=svac_… \
  --set ANTHROPIC_WORKSPACE_ID=wrkspc_…
```

## Use it

`useAnthropic()` returns an [Anthropic SDK](https://github.com/anthropics/anthropic-sdk-typescript)
client that does the exchange and renews the token before it runs out. Add the SDK to the app
(`@anthropic-ai/sdk`), then:

```ts [server/api/ask.post.ts]
import { useAnthropic } from '@wervt/nuxt/anthropic'

export default defineEventHandler(async (event) => {
  const { question } = await readBody(event)
  const message = await useAnthropic().messages.create({
    model: 'claude-sonnet-5-5',
    max_tokens: 1024,
    messages: [{ role: 'user', content: question }],
  })
  return message.content
})
```

With [TanStack AI](https://tanstack.com/ai), hand it the client:
`createAnthropicChatWithClient('claude-sonnet-5-5', useAnthropic())`.

In `nuxt dev` there is no issuer: `useAnthropic()` uses `ANTHROPIC_API_KEY` from your local env,
or `useAnthropic({ devApiKey })`. On wervt it never falls back to a key: missing IDs are an error.

For other providers, `useWorkloadIdentity().token(audience)` (`@wervt/nuxt/server`) returns the
raw signed token. Only audiences wervt knows are signed; today that's `https://api.anthropic.com`.

## What the token says

```json
{
  "iss": "https://id.lightdrop.cloud",
  "sub": "wervt:app:todos:3f9c2a71e0b4d815",
  "aud": "https://api.anthropic.com",
  "exp": 1793000300,
  "jti": "…",
  "wervt_app": "todos",
  "wervt_owner": "you@example.com",
  "wervt_env": "production",
  "wervt_release": "20261026123456-a1b2c3"
}
```

- The subject's last part is fixed while the app exists. Delete the app and claim the name again,
and it changes: someone else who takes a freed name doesn't get your rules. Match the exact
subject in every rule, never a prefix like `wervt:app:`, which would trust every app on wervt.
- `wervt_owner` is the owner's email. A rule on it (a CEL condition) trusts all apps of that
account, and follows the app if it's handed to someone else.
- Tokens last 5 minutes and are single-use. An app gets up to 10 a minute.

## Turn it off

`wervt identity disable todos` stops signing right away; Anthropic tokens the app already has
run out within minutes. Deleting the app does the same, for good.


## Sitemap

See the full [sitemap](https://docs.lightdrop.cloud/sitemap.md) for all pages.
