fix: implement OpenAI-compatible generation for 5 AI stubs (#450)#467
fix: implement OpenAI-compatible generation for 5 AI stubs (#450)#467nikos1005 wants to merge 1 commit into
Conversation
Replace stub placeholder responses with real API calls for kimi, cohere, novita, venice, parasail using their OpenAI-compatible chat-completions endpoints.
Greptile SummaryThis PR replaces stub placeholder responses with real OpenAI-compatible API calls across five AI adapter packages: kimi, cohere, novita, venice, and parasail. The implementation follows the established adapter pattern already used by deepseek, cerebras, and others in the codebase.
Confidence Score: 3/5Two of the five adapters (cohere and venice) will fail every live API call because their default base URLs point to non-existent paths; merging as-is means those integrations are broken out of the box. The kimi, novita, and parasail adapters are solid and match the established codebase pattern. However, cohere uses https://api.cohere.ai/v1/chat/completions when the correct OpenAI-compatible path is https://api.cohere.ai/compatibility/v1/chat/completions, and venice uses https://api.venice.ai/v1/chat/completions when the correct base is https://api.venice.ai/api/v1. Both errors will cause every non-dry-run request to fail immediately. packages/ai/cohere/src/index.ts and packages/ai/venice/src/index.ts need their DEFAULT_BASE constants corrected before merge. Important Files Changed
Sequence DiagramsequenceDiagram
participant C as Caller
participant A as Adapter (generate)
participant V as Vault (ctx.secret)
participant API as Provider API
C->>A: generate(ctx, prompt, opts, config)
A->>V: ctx.secret(API_KEY_NAME)
V-->>A: apiKey
A->>A: build messages array (system + user)
alt ctx.dryRun
A-->>C: "{ text: '[dry-run]', model }"
else live call
A->>API: POST /v1/chat/completions (Bearer apiKey)
alt HTTP 2xx
API-->>A: "{ choices, model, usage }"
A-->>C: "{ text, model, inputTokens, outputTokens }"
else HTTP error
API-->>A: error status
A-->>C: throws Error("Provider STATUS: …")
end
end
Reviews (1): Last reviewed commit: "fix: implement OpenAI-compatible generat..." | Re-trigger Greptile |
| baseUrl?: string; | ||
| } | ||
|
|
||
| const DEFAULT_BASE = 'https://api.venice.ai'; |
There was a problem hiding this comment.
Wrong base URL path for Venice API
The Venice API base URL is https://api.venice.ai/api/v1, not https://api.venice.ai/v1. With the current DEFAULT_BASE, every request will be sent to https://api.venice.ai/v1/chat/completions, which does not exist and will return a 404. The official Venice docs confirm the base URL as https://api.venice.ai/api/v1.
| baseUrl?: string; | ||
| } | ||
|
|
||
| const DEFAULT_BASE = 'https://api.cohere.ai'; |
There was a problem hiding this comment.
Wrong base URL path for Cohere's OpenAI-compatible endpoint
Cohere's OpenAI-compatible chat completions endpoint is at https://api.cohere.ai/compatibility/v1/chat/completions, not https://api.cohere.ai/v1/chat/completions. The current DEFAULT_BASE will produce requests to the wrong path, which will fail at runtime. The official Cohere compatibility docs confirm this path.
Summary
Replaces stub placeholder responses with real OpenAI-compatible API calls for 5 AI adapter packages:
Changes
https://api.moonshot.cn/v1/chat/completionshttps://api.cohere.ai/v1/chat/completionshttps://api.novita.ai/v1/chat/completionshttps://api.venice.ai/v1/chat/completionshttps://api.parasail.io/v1/chat/completionsImplementation details
Each adapter now:
config.baseUrlwith sensible defaults per providermaxTokens,temperature, andopts.extrachoices[0].message.content, response model, and token usagedryRunbehaviorFixes #450