Built-in servicesAIDetails
Streams, embeddings and the model packages
How a provider package maps streams and embeddings, and what Jadpo's own OpenAI, Anthropic and Gemini packages send. You need the mapping rules only to write a package; an app picks a package and connects it (Connecting a provider).
stream:takescall:,input:andpieces:, required, andrefused_when:,cut_off_when:,done_when:andusage:.call:is an operation that changes nothing, asgenerate:'s, its output type the shape of one event's data; its input is mapped asgenerate:'s, and a value written there (stream: true) asks the provider to stream.pieces: event.<field>...is where an event's piece of text is,firsta list's first item and a field after a list with nofirstevery item's text joined, asanswer:reads them;cut_off_when:anddone_when:are{ path: equals: }on each event as sent. A stream is whole atdata: [DONE]or an eventdone_when:marks; anerrorevent, or one with anerrormember, breaks it; an event that marks nothing and has no text (a ping, a thinking block's) is passed over. Its events are read on the answer as sent, not decoded, since a provider's events differ in shape; their type checks the mapping and the stream's recording.usage:is read and checked but not counted, since a stream is charged the whole of the most it could use.embed:takescall:,input:,vectors:,vector:,batch:andusage:, required, andindex:. Its input mapsrequest.model,request.texts(onto a list of text) andrequest.dimensions,ai: { embedding_dimensions: }, besides settings and values; or, for a provider that takes a request for each text,{ each: request.texts as: { } }onto a list of objects,itemthe text andrequest.modelandrequest.dimensionsas outside it. The texts are required, one way or the other;vectors: response.<field>is the answer's list of objects,vector: item.<field>each item's vector (aVectoror a list of numbers) andindex: item.<field>its place among the texts.batch:is the most texts the provider takes at once, from 1: anai.embed_allof more is sent as several requests ofbatch:texts, one after another in order, within the call's onetimeout:. Their vectors are joined in the texts' order and their usage added up, so the call is one step, one recording and one charge. A request that fails ends the call with its failure, and nothing after it is sent. A text longer than the model's context in the package's table istoo_longbefore sending. The answer is decoded by the package's types, then kept in the built-in driver's form,usage.prompt_tokensfromusage: { input: }, so a rerun, a record and the budget read it as theirs.refused_when:is a place that holds anything, or{ holds: <place> path: "<member>" equals: <value> }, any of them saying so, since OpenAI marks a refusal with a field and its content filter with a finish reason.equals:may list values, any of them saying so, as Gemini stops a candidate for its content with one of several.answer:reads every item of a list where a field follows the list with nofirst(response.content.text), their texts joined in order and the items with none left out, as Anthropic answers in content blocks, a thinking block among them with no text.schema: { envelope: }names the envelope's shape:AiEnvelope.openai(the default,{"type": "json_schema", "json_schema": {"name", "strict", "schema"}}),AiEnvelope.anthropic({"type": "json_schema", "schema"}atoutput_config.format) orAiEnvelope.gemini("responseMimeType": "application/json"and"responseJsonSchema", written beside what the mapping puts atat:, Gemini'sgenerationConfig, which holdsmaxOutputTokenstoo), with the schema cut as Generating, its fake and the local driver says, which Anthropic's and Gemini's structured outputs also take; Gemini's has noconst, so aconstgoes as anenumof its one value. Gemini'sjson_onlyis"responseMimeType": "application/json"alone. Anthropic has no JSON-only mode, sojson_onlywith its envelope, and any envelope withnone, ispackage.provider_invalid. Wherever an envelope is an object and the mapping has already written an object atat:, the envelope's members go beside the mapping's.CredentialScheme.headersends the credential alone in the headercredential_header:names (Anthropic'sx-api-key, Gemini'sx-goog-api-key), a new provider key required for it and only for it; andheaders:, another new key, lists the fixed headers every request carries, each"Name: value"(Anthropic'santhropic-version: 2023-06-01). Neither may name a header the driver writes itself (Authorization,Content-Type,Accept,User-Agent,Host,Content-Lengthand AWS's own). The surface record lists both.- A sandbox's embeddings. A connection's
development: { sandbox: }may nameembed, the operation embeddings are logged as, when it is theai:connection and its package mapsembed:. - A provider package's types read its answers leniently (a
T?member left out isnone, a member the type doesn't declare ignored) whether or not a connection names the package, sojadpo package checkdecodes its recordings as an app does. ai: { prices: }sets a price for a model by its name inmodels:, overriding its package's table:input:andoutput:, required, andcached:(the input's when left out), each aMoneysetting giving the price per million tokens, all three in one currency (misconfiguredat the call otherwise). A price for a modelmodels:doesn't name, or one that isn't money, isai.settings_invalid.- The OpenAI package,
OpenAi.v1, one of Jadpo's own, installed withjadpo package add @jadpo/open-ai, is written from OpenAI's API reference and model pages: Chat Completions,POST /chat/completionswithmodel,messages(the instructions as thesystemmessage),max_completion_tokens(max_tokensis deprecated) and the strictresponse_format; the answerchoices.0.message.content; refused formessage.refusalor acontent_filterfinish, cut off for alengthfinish; usageprompt_tokens,completion_tokensandprompt_tokens_details.cached_tokens. It streams the same request with"stream": true(its own input type, so a request that doesn't stream sends nostream), each event'schoices.0.delta.contenta piece, ended bydata: [DONE]; and embeds throughPOST /embeddingswithmodel,inputanddimensions, readingdata[i].embeddingbyindex, up to 2,048 texts a request. Its key is a bearer credential; the connection giveshost:,https://api.openai.com/v1, so a compatible gateway or a test's server can stand in. Its failures are its operations' (error.code), and none is mapped. So a refusal of the request ismisconfigured, and a429or5xxisunavailable, as for every package's operation. - The Anthropic package,
Anthropic.v1, one of Jadpo's own, installed withjadpo package add @jadpo/anthropic, is written from Anthropic's Messages reference and guides:POST /v1/messageswithmodel,max_tokens,system(the instructions) andmessages, the schema atoutput_config.format(its structured outputs, out of beta;output_formatis deprecated); the answer everytextblock's text; refused for arefusalstop reason, cut off formax_tokens; usageinput_tokens,output_tokensandcache_read_input_tokens. It streams the same request with"stream": true, eachcontent_block_delta'sdelta.texta piece, amessage_delta'sdelta.stop_reasonmarking a refusal or a cut-off, ended bymessage_stop. Its key goes inx-api-keyand its version,2023-06-01, inanthropic-version; errors areerror.type. Anthropic has no embeddings endpoint, so the package maps noembed:, and an app embedding through it isai.settings_invalidat the call. Its current models think by default, and their thinking counts againstmax_tokens, so againstmax_output:; the package leaves thinking as each model sets it, since the setting that turns it down differs by model. - The Gemini package,
Gemini.v1, is written from Google's Gemini API reference and guides, throughgenerateContent, which the reference marks legacy but supported, rather than the Interactions API it leads with, since onlygenerateContentdocuments why a candidate stopped and why a prompt was blocked, which a refusal and a cut-off are read from, and it keeps nothing unless asked.POST /v1beta/models/{model}:generateContenttakessystemInstruction(the instructions, one text part),contents(each message a turn of one text part,roleuserormodel, the model's turns spelledmodel),generationConfigwithmaxOutputTokensand the schema'sresponseMimeTypeandresponseJsonSchema, andstore: false; the answer is every text part of the first candidate, a function call's part having none; refused whenpromptFeedback.blockReasonholds anything or the candidate'sfinishReasonisSAFETY,RECITATION,BLOCKLIST,PROHIBITED_CONTENTorSPII, cut off atMAX_TOKENS; usagepromptTokenCount,candidatesTokenCountandthoughtsTokenCountadded up as output, since thinking is billed as output, andcachedContentTokenCount. It streams the same request throughstreamGenerateContent?alt=sse, each event a whole response with a piece of the answer, refused and cut off asgenerate, whole atSTOP; and embeds throughbatchEmbedContents, a request for each text namingmodels/<model>withembedContentConfig.outputDimensionality, readingembeddings[i].valuesin the texts' order, up to 100 texts a request (the reference gives no limit; 100 isai.embed_all's own). Its key goes inx-goog-api-key; the connection giveshost:,https://generativelanguage.googleapis.com. Errors are read aterror.status, and none is mapped. Its models think by default; the package leaves thinking as each model sets it and sends no tools, since tool calling is left to packages (Questions, 1). - The tables come from the providers' own pages, and are refreshed
whenever those change. They hold context windows of 1,050,000
tokens for
gpt-6-astra,gpt-6.1-solandgpt-6-luna, 8,192 tokens a text fortext-embedding-3-smalland-large, and 1M (taken as 1,000,000) forclaude-fable-5-1,claude-opus-5-5,claude-sonnet-5-5andclaude-haiku-5-5; standard prices per million input, cached and output tokens in US dollars, from 2026-10-20: OpenAI's 10.00, 1.00 and 50.00 (Astra), 2.00, 0.10 and 10.00 (Sol), and 0.10, 0.01 and 0.50 (Luna), its embedding models' 0.02 and 0.13 input (no output; cached repeating input, which OpenAI doesn't publish); Anthropic's 10.00, 0.25 and 50.00 (Fable 5.1), 4.00, 0.20 and 20.00 (Opus 5.5), 2.00, 0.10 and 10.00 (Sonnet 5.5), and 0.10, 0.01 and 0.50 (Haiku 5.5, for prompts up to 100,000 tokens). Gemini's hold 1,048,576 forgemini-4-hydrogenandgemini-3.8-flash, 1M (taken as 1,000,000, as only the overview gives it) forgemini-4-carbon,gemini-4-neonandgemini-4-argon, and 8,192 and 2,048 tokens a text forgemini-embedding-2andgemini-embedding-001; from 2026-12-01, 1.50, 0.075 and 7.50 (Hydrogen), 4.00, 0.20 and 20.00 (Carbon and Argon), 3.00, 0.15 and 15.00 (Neon), 0.75, 0.075 and 3.75 (3.8 Flash, 1.50, 0.15 and 7.50 from 2027-01-01), and 0.20 and 0.15 input for its embedding models. Long-prompt prices (OpenAI's past 272,000 input tokens, Haiku 5.5's past 100,000), batch, fast, flex, priority and regional prices, cache writes and Gemini's cache storage aren't held; an app that needs them setsai: { prices: }. - Recordings. Each package keeps a recording of each operation,
recordings/<resource>.<operation>.json, made byjadpo package recordfrom the answer each provider's documentation shows, sent by a server in the test, never a live call: a stream's is one event, a piece of text. A test records them again from the same answers and compares them with the files, andjadpo testdecodes them. - The documentation used:
- OpenAI: https://developers.openai.com/api/reference/resources/chat/subresources/completions/methods/create,
https://developers.openai.com/api/reference/resources/chat/subresources/completions/streaming-events,
https://developers.openai.com/api/reference/resources/embeddings/methods/create,
https://developers.openai.com/api/docs/guides/structured-outputs,
https://developers.openai.com/api/docs/guides/error-codes,
https://developers.openai.com/api/docs/models, each model's page
under https://developers.openai.com/api/docs/models/ (
gpt-6-astra,gpt-6.1-sol,gpt-6-luna,text-embedding-3-small,text-embedding-3-large), and https://developers.openai.com/api/docs/pricing. - Anthropic: https://platform.claude.com/docs/en/api/messages/create, https://platform.claude.com/docs/en/build-with-claude/streaming, https://platform.claude.com/docs/en/build-with-claude/structured-outputs, https://platform.claude.com/docs/en/build-with-claude/thinking, https://platform.claude.com/docs/en/api/errors, https://platform.claude.com/docs/en/api/versioning, https://platform.claude.com/docs/en/about-claude/models/overview, https://platform.claude.com/docs/en/build-with-claude/context-windows and https://platform.claude.com/docs/en/about-claude/pricing.
- Gemini, read on 2026-12-01 (each
ai.google.devpage now redirects to the same path underaistudio.google.com): https://ai.google.dev/api, https://ai.google.dev/api/generate-content and its methodsgenerate-contentandstream-generate-content, https://ai.google.dev/api/embeddings and its methodbatch-embed-contents, https://ai.google.dev/gemini-api/docs/text-generation, https://ai.google.dev/gemini-api/docs/structured-output, https://ai.google.dev/gemini-api/docs/embeddings, https://ai.google.dev/gemini-api/docs/migrate-to-interactions, https://ai.google.dev/gemini-api/docs/models with the pages ofgemini-4-hydrogenandgemini-3.8-flash, and https://ai.google.dev/gemini-api/docs/pricing. Its reference shows no sample answer, so its recordings are made from answers holding the members the reference lists.
- OpenAI: https://developers.openai.com/api/reference/resources/chat/subresources/completions/methods/create,
https://developers.openai.com/api/reference/resources/chat/subresources/completions/streaming-events,
https://developers.openai.com/api/reference/resources/embeddings/methods/create,
https://developers.openai.com/api/docs/guides/structured-outputs,
https://developers.openai.com/api/docs/guides/error-codes,
https://developers.openai.com/api/docs/models, each model's page
under https://developers.openai.com/api/docs/models/ (
Markdown for agents: /docs/streams-embeddings-and-the-model-packages.md.Built from Jadpo's main branch at commit 72d483f.