Docs

AI

AI is a resource that gives your code model inference through the customer's own Amazon Bedrock, Vertex AI, or Azure AI Foundry, with no API key in your application. It fits when your product calls language models from inside a deployment and the customer wants inference on their account, under their quotas and data-handling terms.

alien.ts
import * as alien from "@alienplatform/core"

const llm = new alien.AI("llm").build()

const api = new alien.Worker("api")
  .code({ type: "source", src: "./api", toolchain: { type: "typescript" } })
  .link(llm)
  .permissions("execution")
  .build()

export default new alien.Stack("acme")
  .platforms(["aws", "gcp", "azure"])
  .add(llm, "frozen")
  .add(api, "live")
  .permissions({ profiles: { execution: { llm: ["ai/invoke"] } } })
  .build()

In this stack:

  • .link(llm) connects the AI resource to the api Worker, the workload (the running code) that uses it. Alien injects the AI resource's connection details, its binding, into the Worker, read by the SDK client.
  • The execution permission profile, the named set of cloud permissions a workload runs with, grants ai/invoke: calling models.
  • "frozen" means the customer's admin creates the AI resource during initial setup. "live" resources, like the Worker, are created and updated by Alien on every release. See Frozen and live.

The api Worker calls a model with an OpenAI-style client:

api/src/summarize.ts
import { ai } from "@alienplatform/sdk"

const completion = await ai("llm").chat.completions.create({
  model: "gpt-oss-120b",
  messages: [{ role: "user", content: "Summarize this order." }],
})

Platforms

llm becomes the AI service in the customer's cloud. Calls are billed to their cloud account and authorized by the workload's own identity.

PlatformBacking serviceWhat Alien provisions
AWSAmazon BedrockNothing. Bedrock is an account-level API, so Alien only grants the workload access.
GCPVertex AIEnables the Vertex AI API and grants a custom prediction-only role.
AzureAzure AI FoundryAn AI Services account with gpt-4.1 and model-router deployments.
Kubernetes, MachinesYour providerNothing. Supply an external AI binding with your provider key.
LocalYour providerNothing. alien dev uses OPENAI_API_KEY, or any OpenAI-compatible server at ALIEN_AI_LOCAL_BASE_URL.

Per-cloud details are in Behavior and limits. The model list for each cloud is in Models.

Bring your own models

AI is the in-deployment way for a customer to bring their own models. Each customer's inference runs in their account, and you ship no keys. The full flow, including open-weight models on the customer's GPUs, is in Local AI models in a deployment.

If your product stays hosted in your cloud, use the AI Gateway instead. See Local AI models.

Model choice

The model menu belongs to the customer's cloud, not to you. What you can call depends on which cloud they run and which models they've enabled.

If your product needs one model everywhere, or a provider none of the clouds host, use an external binding with your own provider key instead.

Frozen or live

AI can be "frozen" or "live". See Frozen and live.

ai/invoke grants inference and nothing else: no model management and no deployment writes.

Options

MemberTypeNotes
new alien.AI(id)stringLetters, digits, hyphens, and underscores, up to 64 characters. Immutable after create.
.enabled(input)boolean stack inputCreates the resource only when the input is true.

There is nothing else to configure. The model, temperature, and every other setting belong to the request.

Changing models doesn't need a release, and one stack works across clouds whose model menus differ.

Use it in code

src/summarize.ts
import { ai } from "@alienplatform/sdk"

const llm = ai("llm")

const completion = await llm.chat.completions.create({
  model: "gpt-oss-120b",
  messages: [{ role: "user", content: "Summarize this order." }],
})
console.log(completion.choices[0]?.message.content)

On a cloud binding, the SDK starts a small gateway process beside your code on first use. It signs each request with the workload's cloud identity and forwards it to the provider. See the API reference.

Any client library

getAiConnection() returns a base URL that works with any OpenAI- or Anthropic-compatible client, including the Vercel AI SDK, the OpenAI SDK, and the Anthropic SDK:

src/claude.ts
import Anthropic from "@anthropic-ai/sdk"
import { getAiConnection } from "@alienplatform/sdk"

const { baseURL, apiKey } = await getAiConnection("llm")
const anthropic = new Anthropic({ baseURL, apiKey: apiKey ?? "" })

const message = await anthropic.messages.create({
  model: "claude-sonnet-4.6",
  max_tokens: 1024,
  messages: [{ role: "user", content: "Summarize this order." }],
})

Pass apiKey: "" on a cloud binding. Most clients otherwise fall back to a key from your environment, such as your personal ANTHROPIC_API_KEY, instead of the workload's identity.

Pick a model at runtime

Model availability differs per cloud and per account. List the models for this deployment instead of hardcoding one:

const models = await ai("llm").getAvailableModels()
// [{ id: "byo/gpt-oss-20b", provider: "openai", displayName: "GPT-OSS 20B" }, …]

Pass an id back as model, with or without the byo/ prefix.

Common patterns

A model picker. Feed getAvailableModels() to a dropdown and send the chosen id with each request. displayName is the human label.

One client for every model. Claude speaks Anthropic Messages, the GPT-5 family speaks OpenAI Responses, and the rest speak Chat Completions. Alien translates between them, so a Chat Completions client can call Claude.

Use the model's native protocol when you need provider-specific features such as extended thinking or prompt caching. See Protocols.

Bring your own key off-cloud. On Kubernetes, Machines, and Local, the same code calls your provider directly with your key. Your code doesn't change between environments.

Local development

There is no cloud identity on your machine, so locally the resource uses your provider key:

OPENAI_API_KEY=sk-... alien dev
  • alien dev fails with an actionable error if the key is missing.
  • Cloud model ids don't apply locally. Pass any model id your key can reach.
  • getAvailableModels() returns a short built-in list instead of querying the provider.
  • To use another OpenAI-compatible server, including one on your machine, set ALIEN_AI_LOCAL_BASE_URL.

Permissions

SetGrants
ai/invokeCalling models.
ai/provisionCreating the AI resource at initial setup.
ai/management, ai/heartbeatUsed by the management identity to read status and model availability.

Next

On this page