Organizations can bring credentials for OpenAI, Anthropic, and Fireworks into
the platform without placing secrets in Worker source or Wrangler configuration.
Workers call the native AI binding and the platform uses the selected
organization-owned connection. Provider accounts, prices, token budgets, and
bills remain the organization’s responsibility.
Vector indexes are a separate primitive. They store and search vectors but do
not choose a model or generate embeddings. A Worker can compose AI.run() with
a Vectorize binding to embed content, store it, search it, and optionally rerank
the results.
Add a provider connection
Open AI → Models in the tenant console and add an OpenAI, Anthropic, or Fireworks API key. A key is encrypted at rest and represented only by a short fingerprint after saving. Each organization can configure at most one connection for each provider type; the human-readable connection name does not change the model identifier used by Workers.
The model name begins with the provider type and the remainder is sent to that provider unchanged. OpenAI supports chat-completion and embeddings through this binding. Fireworks supports chat-completion, embeddings, and reranking. Anthropic currently supports message generation. For Fireworks:
const answer = await env.AI.run(
"fireworks/accounts/fireworks/models/glm-5p3-flash",
{ messages: [{ role: "user", content: "Summarize this document." }] },
);
const embeddings = await env.AI.run(
"fireworks/accounts/fireworks/models/qwen3-embedding-8b",
{ text: [document], dimensions: 1024 },
);
const ranked = await env.AI.run(
"fireworks/accounts/fireworks/models/qwen3-reranker-8b",
{ query, documents, top_n: 10 },
);Task selection follows the input contract rather than a model-name allowlist.
messages selects generation, text or input selects embeddings, and
query plus documents selects reranking. Pass { task: "..." } as the third
argument to AI.run() when an unusual provider payload is ambiguous.
The platform does not add a model-result cache or own provider spend. Provider
options such as prompt-cache keys pass through in generation payloads, and
provider usage/cache fields pass through in generation responses. Embedding
responses use the Workers AI-style { shape, data, usage } structure so their
vectors can be inserted directly.
Declare the binding in Wrangler:
[ai]
binding = "AI"Create and bind a vector index
Use the tenant console under AI → Vector indexes, or use ordinary Wrangler commands after connecting Wrangler:
npx wrangler vectorize create documents --dimensions 1024 --metric cosine
npx wrangler vectorize info documentsThen bind the index by name:
[[vectorize]]
binding = "VECTORIZE"
index_name = "documents"The Worker-facing binding implements describe(), insert(), upsert(),
query(), queryById(), getByIds(), and deleteByIds(). Wrangler’s create,
list, get, delete, insert, upsert, query, list-vectors, get-vectors,
delete-vectors, and info commands use the same organization-scoped service.
const { data } = await env.AI.run(
"fireworks/accounts/fireworks/models/qwen3-embedding-8b",
{ text: [document], dimensions: 1024 },
);
await env.VECTORIZE.upsert([
{ id: documentId, values: data[0], metadata: { title } },
]);
const query = await env.AI.run(
"fireworks/accounts/fireworks/models/qwen3-embedding-8b",
{ text: [searchText], dimensions: 1024 },
);
const matches = await env.VECTORIZE.query(query.data[0], {
topK: 10,
returnMetadata: "all",
});Indexes use 1–1,536 dimensions and cosine, Euclidean, or dot-product distance. Writes contain at most 1,000 vectors and queries return at most 100 matches. Vector IDs are unique within an index; a namespace can partition searches but does not create a second identity space. Metadata filters currently perform exact field matches.
Indexes provide exact local search over an organization-scoped SQLite catalog. They are appropriate for development and moderate evaluation workloads, not a distributed approximate-nearest-neighbor service. Index data is not replicated or automatically failed over.
Security, limits, and verification
Worker bindings are resource-scoped capabilities. Worker code receives neither the provider credential nor the vector service credential, and index management continues to require organization RBAC.
Usage & limits enforces provider count, inference count, index count, stored vector count, and vector operation limits. Growth fails closed if quota enforcement is unavailable; deletion remains possible. Models and Vector operations appear in organization-scoped activity and platform telemetry, but provider credentials, prompts, vectors, and returned content are not recorded.
The photo example uses these capabilities for structured descriptions and tags. Operators can validate provider and vector integration using capability checks.