@warlock.js/ai-openai 5.26.0 → 5.28.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (38) hide show
  1. package/CHANGELOG.md +14 -0
  2. package/cjs/index.cjs +958 -280
  3. package/cjs/index.cjs.map +1 -1
  4. package/esm/config.type.d.mts +22 -0
  5. package/esm/config.type.d.mts.map +1 -1
  6. package/esm/model.mjs +26 -119
  7. package/esm/model.mjs.map +1 -1
  8. package/esm/responses-model.mjs +329 -0
  9. package/esm/responses-model.mjs.map +1 -0
  10. package/esm/sdk.d.mts +7 -0
  11. package/esm/sdk.d.mts.map +1 -1
  12. package/esm/sdk.mjs +21 -1
  13. package/esm/sdk.mjs.map +1 -1
  14. package/esm/utils/build-usage.mjs +23 -0
  15. package/esm/utils/build-usage.mjs.map +1 -0
  16. package/esm/utils/index.mjs +9 -1
  17. package/esm/utils/map-responses-status.mjs +54 -0
  18. package/esm/utils/map-responses-status.mjs.map +1 -0
  19. package/esm/utils/prompt-cache-params.mjs +17 -0
  20. package/esm/utils/prompt-cache-params.mjs.map +1 -0
  21. package/esm/utils/reasoning-effort.mjs +35 -0
  22. package/esm/utils/reasoning-effort.mjs.map +1 -0
  23. package/esm/utils/reasoning-replay.mjs +85 -0
  24. package/esm/utils/reasoning-replay.mjs.map +1 -0
  25. package/esm/utils/structured-output.mjs +84 -0
  26. package/esm/utils/structured-output.mjs.map +1 -0
  27. package/esm/utils/to-openai-messages.mjs +9 -2
  28. package/esm/utils/to-openai-messages.mjs.map +1 -1
  29. package/esm/utils/to-openai-tools.mjs +3 -3
  30. package/esm/utils/to-openai-tools.mjs.map +1 -1
  31. package/esm/utils/to-responses-input.mjs +112 -0
  32. package/esm/utils/to-responses-input.mjs.map +1 -0
  33. package/esm/utils/to-responses-tools.mjs +51 -0
  34. package/esm/utils/to-responses-tools.mjs.map +1 -0
  35. package/llms-full.txt +20 -3
  36. package/llms.txt +1 -1
  37. package/package.json +3 -3
  38. package/skills/setup-openai/SKILL.md +20 -3
@@ -1,6 +1,6 @@
1
1
  ---
2
2
  name: setup-openai
3
- description: 'Wire @warlock.js/ai-openai — new OpenAISDK({apiKey, baseURL?, provider?, pricing?}) for OpenAI / Azure / OpenRouter, .model({name, vision?, reasoning?, structuredOutput?, responseFormat?, pdf?, audio?}) for ModelContract, .embedder({name, dimensions?}) for embeddings, .image({name, pricing?}) for gpt-image-*/dall-e-* image generation (via ai.image). PDF input maps to OpenAI file parts (opt-in pdf:true), audio input to input_audio (opt-in audio:true). Triggers: `OpenAISDK`, `.model`, `.embedder`, `.image`, `.embed`, `.embedMany`, `baseURL`, `pricing`, `responseSchema`, `responseFormat`, `reasoning_effort`, `reasoningTokens`, `cachedTokens`, `gpt-image`, `dall-e`, `ai.image`, `pdf input`, `input_audio`, o-series / gpt-5 reasoning, prompt caching; "wire openai into a warlock agent", "configure gpt-4o", "use o3 / gpt-5 reasoning effort", "route through openrouter or azure openai", "openai embeddings with warlock", "generate images with gpt-image / dall-e", "send a pdf / audio to gpt-4o"; typical import `import { OpenAISDK } from "@warlock.js/ai-openai"`. Skip: the ai.image verb surface — `@warlock.js/ai/generate-images/SKILL.md`; agent wiring — `@warlock.js/ai/run-ai-agent/SKILL.md`; adapter comparison — `@warlock.js/ai/pick-ai-provider/SKILL.md`; competing adapters `@warlock.js/ai-anthropic`, `@warlock.js/ai-bedrock`, `@warlock.js/ai-google`, `@warlock.js/ai-ollama`; raw `openai` SDK, Vercel `@ai-sdk/openai`.'
3
+ description: 'Wire @warlock.js/ai-openai — new OpenAISDK({apiKey, baseURL?, provider?, pricing?}) for OpenAI / Azure / OpenRouter, .model({name, vision?, reasoning?, structuredOutput?, responseFormat?, pdf?, audio?}) for ModelContract, .embedder({name, dimensions?}) for embeddings, .image({name, pricing?}) for gpt-image-*/dall-e-* image generation (via ai.image). PDF input maps to OpenAI file parts (opt-in pdf:true), audio input to input_audio (opt-in audio:true). Triggers: `OpenAISDK`, `.model`, `.embedder`, `.image`, `.embed`, `.embedMany`, `baseURL`, `pricing`, `responseSchema`, `responseFormat`, `reasoning_effort`, `reasoningTokens`, `cachedTokens`, `gpt-image`, `dall-e`, `ai.image`, `pdf input`, `input_audio`, o-series / gpt-5 reasoning, `api: "responses"`, Responses API, reasoning with tools, prompt caching; "wire openai into a warlock agent", "configure gpt-4o", "use o3 / gpt-5 reasoning effort", "route through openrouter or azure openai", "openai embeddings with warlock", "generate images with gpt-image / dall-e", "send a pdf / audio to gpt-4o"; typical import `import { OpenAISDK } from "@warlock.js/ai-openai"`. Skip: the ai.image verb surface — `@warlock.js/ai/generate-images/SKILL.md`; agent wiring — `@warlock.js/ai/run-ai-agent/SKILL.md`; adapter comparison — `@warlock.js/ai/pick-ai-provider/SKILL.md`; competing adapters `@warlock.js/ai-anthropic`, `@warlock.js/ai-bedrock`, `@warlock.js/ai-google`, `@warlock.js/ai-ollama`; raw `openai` SDK, Vercel `@ai-sdk/openai`.'
4
4
  ---
5
5
 
6
6
  # `@warlock.js/ai-openai`
@@ -155,9 +155,26 @@ The gpt-6 models (`gpt-6-astra` / `gpt-6-sol` / `gpt-6-luna`) are hard-400 cases
155
155
  400 Function tools with reasoning_effort are not supported for gpt-6-sol in /v1/chat/completions. To use function tools, use /v1/responses or set reasoning_effort to 'none'.
156
156
  ```
157
157
 
158
- Tools work with reasoning off (the adapter's default when tools are present and no reasoning is set). Responses API support, planned for 5.27, lifts this.
158
+ Tools work with reasoning off (the adapter's default when tools are present and no reasoning is set). For reasoning **and** tools together, use the Responses API below.
159
159
 
160
- Calling **without** `tools` is unaffected — `reasoning_effort` is still omitted by default in that case (provider default reasoning, nothing to unblock). Trade-off of the `"none"` default: you lose reasoning on that call. For tool-heavy agent work (function calls + good replies rather than deep analysis) this is the right call — it's the difference between empty replies and working ones. When you need reasoning **and** tools together, use the Responses API (planned).
160
+ Calling **without** `tools` is unaffected — `reasoning_effort` is still omitted by default in that case (provider default reasoning, nothing to unblock). Trade-off of the `"none"` default: you lose reasoning on that call. For tool-heavy agent work (function calls + good replies rather than deep analysis) this is the right call — it's the difference between empty replies and working ones. When you need reasoning **and** tools together, use the Responses API (next section).
161
+
162
+ ### Reasoning + tools: the Responses API (`api: "responses"`)
163
+
164
+ Opt a direct-OpenAI model into `/v1/responses`, where reasoning models accept function tools with reasoning on:
165
+
166
+ ```ts
167
+ const model = openai.model({ name: "gpt-6-sol", api: "responses" });
168
+ await model.complete(messages, { tools, reasoning: { effort: "high" } }); // reasoning stays on, tools work
169
+ ```
170
+
171
+ - Chat Completions stays the default; nothing changes unless you pass `api: "responses"`.
172
+ - Only the direct `openai` provider accepts it. `@warlock.js/ai-deepseek`, `ai-groq`, `ai-xai` and `ai-mistral` (which reuse this adapter with their own `baseURL`) reject `api: "responses"` with `InvalidRequestError`.
173
+ - With tools attached, reasoning uses the provider default instead of being forced to `"none"`: expect more reasoning tokens and latency than the Chat path. Pass `reasoning: { effort }` to choose.
174
+ - The system prompt is sent as `instructions`; requests use `store: false` (no server-side conversation state).
175
+ - Reasoning is carried across a tool loop without server storage: each response asks for encrypted reasoning, which rides on the first tool call of the turn (`providerMetadata.openaiResponses`) and is sent back on the next request when the model is the same. It is persisted with your conversation history.
176
+ - `complete()` and `stream()` both work; streamed chunks follow the same order as the Chat path (deltas, then tool calls, then `done`). Usage reports `reasoningTokens` and `cachedTokens` the same way.
177
+ - `pdf` and `audio` inputs are not available on this path.
161
178
 
162
179
  ## Token usage — what's reported
163
180