MCPcopy
hub / github.com/di-sukharev/opencommit / OpenRouterEngine

Class OpenRouterEngine

src/engine/openrouter.ts:9–40  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

7interface OpenRouterConfig extends AiEngineConfig {}
8
9export class OpenRouterEngine implements AiEngine {
10 client: AxiosInstance;
11
12 constructor(public config: OpenRouterConfig) {
13 this.client = axios.create({
14 baseURL: 'https://openrouter.ai/api/v1/chat/completions',
15 headers: {
16 Authorization: `Bearer ${config.apiKey}`,
17 'HTTP-Referer': 'https://github.com/di-sukharev/opencommit',
18 'X-Title': 'OpenCommit',
19 'Content-Type': 'application/json'
20 }
21 });
22 }
23
24 public generateCommitMessage = async (
25 messages: Array<OpenAI.Chat.Completions.ChatCompletionMessageParam>
26 ): Promise<string | null> => {
27 try {
28 const response = await this.client.post('', {
29 model: this.config.model,
30 messages
31 });
32
33 const message = response.data.choices[0].message;
34 let content = message?.content;
35 return removeContentTags(content, 'think');
36 } catch (error) {
37 throw normalizeEngineError(error, 'openrouter', this.config.model);
38 }
39 };
40}

Callers

nothing calls this directly

Calls 3

removeContentTagsFunction · 0.90
normalizeEngineErrorFunction · 0.90
postMethod · 0.80

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…