Skip to content

feat(api): add provider-agnostic project AI chat endpoint with provider registry#1

Closed
flooryyyy wants to merge 1 commit intomainfrom
codex/update-chat-completion-api-for-providers
Closed

feat(api): add provider-agnostic project AI chat endpoint with provider registry#1
flooryyyy wants to merge 1 commit intomainfrom
codex/update-chat-completion-api-for-providers

Conversation

@flooryyyy
Copy link
Copy Markdown
Owner

Motivation

  • Provide a single project-scoped AI chat endpoint that can work with multiple AI providers and provider configs.
  • Allow selecting a specific provider by slug or falling back to the configured default to simplify client integration.
  • Decouple provider-specific request/response handling from route logic via a registry to make adding new providers easier.
  • Normalize completions into a stable response shape so callers don't need to handle provider-specific payloads.

Description

  • Add POST /api/projects/[id]/ai/chat with request validation and provider selection by explicit providerSlug or default provider, returning a normalized completion payload (src/app/api/projects/[id]/ai/chat/route.ts).
  • Introduce shared AI types and normalized response contract including AiProviderConfig, ChatCompletionRequest, and NormalizedChatCompletion (src/app/lib/ai/providers/types.ts).
  • Add a provider registry that resolves provider configs and dispatches chat completion to the correct executor by provider type (src/app/lib/ai/registry.ts).
  • Implement OpenAI/OpenAI-compatible and Anthropic executors that handle provider-specific APIs, extract model/usage/content, and return the normalized shape (src/app/lib/ai/providers/openai.ts, src/app/lib/ai/providers/anthropic.ts).

Testing

  • Ran static checks with npm run check which succeeded.
  • Ran automated tests with npm run test which passed (55 tests passed).

Codex Task

@flooryyyy flooryyyy closed this Apr 10, 2026
@flooryyyy flooryyyy deleted the codex/update-chat-completion-api-for-providers branch April 10, 2026 16:04
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant