Skip to content

fix: implement OpenAI-compatible generation for 5 AI stubs (#450)#467

Open
nikos1005 wants to merge 1 commit into
profullstack:masterfrom
nikos1005:fix/ai-stubs-openai-compatible
Open

fix: implement OpenAI-compatible generation for 5 AI stubs (#450)#467
nikos1005 wants to merge 1 commit into
profullstack:masterfrom
nikos1005:fix/ai-stubs-openai-compatible

Conversation

@nikos1005
Copy link
Copy Markdown

Summary

Replaces stub placeholder responses with real OpenAI-compatible API calls for 5 AI adapter packages:

Changes

  • kimi (Moonshot): https://api.moonshot.cn/v1/chat/completions
  • cohere: https://api.cohere.ai/v1/chat/completions
  • novita: https://api.novita.ai/v1/chat/completions
  • venice: https://api.venice.ai/v1/chat/completions
  • parasail: https://api.parasail.io/v1/chat/completions

Implementation details

Each adapter now:

  • Uses config.baseUrl with sensible defaults per provider
  • Forwards system/user messages, maxTokens, temperature, and opts.extra
  • Maps choices[0].message.content, response model, and token usage
  • Preserves existing dryRun behavior
  • Throws descriptive errors on API failures

Fixes #450

Replace stub placeholder responses with real API calls for kimi, cohere, novita, venice, parasail using their OpenAI-compatible chat-completions endpoints.
@greptile-apps
Copy link
Copy Markdown
Contributor

greptile-apps Bot commented May 29, 2026

Greptile Summary

This 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.

  • kimi, novita, parasail: Correctly implement OpenAI-compatible generation; parasail also fixes pre-existing stub bugs where the API key name was used as the model and a URL was used as the secret key.
  • cohere: The DEFAULT_BASE resolves to https://api.cohere.ai/v1/chat/completions, but Cohere's OpenAI-compatible endpoint lives under a /compatibility prefix — requests will fail at runtime without this correction.
  • venice: The DEFAULT_BASE is missing the /api path segment; the correct base is https://api.venice.ai/api/v1, so all requests will hit a non-existent path.

Confidence Score: 3/5

Two 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

Filename Overview
packages/ai/cohere/src/index.ts Replaces stub with real API call, but DEFAULT_BASE points to the wrong path — Cohere's OpenAI-compatible endpoint requires a /compatibility prefix that is missing.
packages/ai/venice/src/index.ts Replaces stub with real API call, but DEFAULT_BASE is missing the /api path segment — the correct Venice base URL is https://api.venice.ai/api/v1.
packages/ai/kimi/src/index.ts Replaces stub with OpenAI-compatible call to Moonshot; endpoint, auth, and response mapping look correct and consistent with other adapters.
packages/ai/novita/src/index.ts Replaces stub with OpenAI-compatible call to Novita; endpoint, auth, and response mapping look correct.
packages/ai/parasail/src/index.ts Fixes multiple stub bugs (API key used as model name, URL used as secret key) and implements correct OpenAI-compatible generation for Parasail.

Sequence Diagram

sequenceDiagram
    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
Loading

Reviews (1): Last reviewed commit: "fix: implement OpenAI-compatible generat..." | Re-trigger Greptile

baseUrl?: string;
}

const DEFAULT_BASE = 'https://api.venice.ai';
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P1 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';
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P1 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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Implement OpenAI-compatible generation for remaining AI stubs

1 participant