[PR #1907] [CLOSED] feat: Replace Chat Completions with Responses API for all OpenAI models #1924

Closed
opened 2026-03-02 11:59:47 +03:00 by kerem · 0 comments
Owner

📋 Pull Request Information

Original PR: https://github.com/karakeep-app/karakeep/pull/1907
Author: @camjac251
Created: 9/7/2025
Status: Closed

Base: mainHead: feat/openai-responses-api


📝 Commits (1)

  • 01a5a62 feat: Replace Chat Completions with Responses API for all OpenAI models

📊 Changes

4 files changed (+171 additions, -139 deletions)

View changed files

📝 packages/shared/config.ts (+9 -2)
📝 packages/shared/inference.ts (+148 -58)
📝 packages/shared/package.json (+1 -1)
📝 pnpm-lock.yaml (+13 -78)

📄 Description

Summary

  • Complete migration from Chat Completions API to Responses API
  • Add support for GPT-5 features (reasoning effort, verbosity control)
  • Model-aware parameter handling (GPT-4 vs GPT-5 capabilities)
  • Upgrade OpenAI SDK from v4.104.0 to v5.19.1
  • Update default models to GPT-5-mini for future readiness
  • No changes to InferenceClient public interface

New Configuration Options

  • INFERENCE_REASONING_EFFORT: Control reasoning depth (minimal/low/medium/high, default: low)
  • INFERENCE_VERBOSITY: Output verbosity for GPT-5 models (low/medium/high, default: medium)
  • Default models updated to gpt-5-mini (configurable via INFERENCE_TEXT_MODEL and INFERENCE_IMAGE_MODEL)

Why this change?

OpenAI's Responses API is the future-facing interface for all their models. Chat Completions is being phased out. This migration is necessary for GPT-5 compatibility and new features like reasoning control.

Key Implementation Details

  • GPT-5 models receive verbosity and full reasoning effort parameters
  • GPT-4 models get empty reasoning object and max_output_tokens parameter
  • Image inference restructured to use input_image format
  • Response extraction handles multiple API response structures
  • Structured output uses direct Zod schema conversion
  • Removed dependency on zodResponseFormat helper

Known Limitations

  • The OpenAI SDK v5 doesn't export TypeScript types for the Responses API yet, requiring use of any types in 4 places (with eslint-disable comments)
  • Once OpenAI adds proper type definitions, these can be replaced with proper types

Testing

  • pnpm typecheck --filter=@karakeep/shared --filter=@karakeep/trpc
  • pnpm lint --filter=@karakeep/shared --filter=@karakeep/trpc
  • Manual testing with real API keys:
    • GPT-4 and GPT-5 model compatibility verified
    • Text inference (bookmark summaries, general queries)
    • Structured output (auto-tagging with Zod schemas)
    • Image analysis (screenshot processing, base64 images)
    • All inference modes tested with production-like payloads

🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.

## 📋 Pull Request Information **Original PR:** https://github.com/karakeep-app/karakeep/pull/1907 **Author:** [@camjac251](https://github.com/camjac251) **Created:** 9/7/2025 **Status:** ❌ Closed **Base:** `main` ← **Head:** `feat/openai-responses-api` --- ### 📝 Commits (1) - [`01a5a62`](https://github.com/karakeep-app/karakeep/commit/01a5a629cf110c5e3e859f2d67df3335918288f7) feat: Replace Chat Completions with Responses API for all OpenAI models ### 📊 Changes **4 files changed** (+171 additions, -139 deletions) <details> <summary>View changed files</summary> 📝 `packages/shared/config.ts` (+9 -2) 📝 `packages/shared/inference.ts` (+148 -58) 📝 `packages/shared/package.json` (+1 -1) 📝 `pnpm-lock.yaml` (+13 -78) </details> ### 📄 Description ## Summary - **Complete migration** from Chat Completions API to Responses API - Add support for GPT-5 features (reasoning effort, verbosity control) - Model-aware parameter handling (GPT-4 vs GPT-5 capabilities) - Upgrade OpenAI SDK from v4.104.0 to v5.19.1 - Update default models to GPT-5-mini for future readiness - No changes to InferenceClient public interface ## New Configuration Options - `INFERENCE_REASONING_EFFORT`: Control reasoning depth (`minimal`/`low`/`medium`/`high`, default: `low`) - `INFERENCE_VERBOSITY`: Output verbosity for GPT-5 models (`low`/`medium`/`high`, default: `medium`) - Default models updated to `gpt-5-mini` (configurable via `INFERENCE_TEXT_MODEL` and `INFERENCE_IMAGE_MODEL`) ## Why this change? OpenAI's Responses API is the future-facing interface for all their models. Chat Completions is being phased out. This migration is necessary for GPT-5 compatibility and new features like reasoning control. ## Key Implementation Details - GPT-5 models receive verbosity and full reasoning effort parameters - GPT-4 models get empty reasoning object and `max_output_tokens` parameter - Image inference restructured to use `input_image` format - Response extraction handles multiple API response structures - Structured output uses direct Zod schema conversion - Removed dependency on `zodResponseFormat` helper ## Known Limitations - The OpenAI SDK v5 doesn't export TypeScript types for the Responses API yet, requiring use of `any` types in 4 places (with eslint-disable comments) - Once OpenAI adds proper type definitions, these can be replaced with proper types ## Testing - `pnpm typecheck --filter=@karakeep/shared --filter=@karakeep/trpc` - `pnpm lint --filter=@karakeep/shared --filter=@karakeep/trpc` - Manual testing with real API keys: - ✅ GPT-4 and GPT-5 model compatibility verified - ✅ Text inference (bookmark summaries, general queries) - ✅ Structured output (auto-tagging with Zod schemas) - ✅ Image analysis (screenshot processing, base64 images) - ✅ All inference modes tested with production-like payloads --- <sub>🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.</sub>
kerem 2026-03-02 11:59:47 +03:00
Sign in to join this conversation.
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
starred/karakeep#1924
No description provided.