diff --git a/pkg/provider/modelmgr/requesters/openrouter.svg b/pkg/provider/modelmgr/requesters/openrouter.svg new file mode 100644 index 00000000..ed81fc04 --- /dev/null +++ b/pkg/provider/modelmgr/requesters/openrouter.svg @@ -0,0 +1,10 @@ + + + + + + + + + + diff --git a/pkg/provider/modelmgr/requesters/openrouterchatcmpl.py b/pkg/provider/modelmgr/requesters/openrouterchatcmpl.py new file mode 100644 index 00000000..a73437d3 --- /dev/null +++ b/pkg/provider/modelmgr/requesters/openrouterchatcmpl.py @@ -0,0 +1,17 @@ +from __future__ import annotations + +import typing +import openai + +from . import modelscopechatcmpl + + +class OpenRouterChatCompletions(modelscopechatcmpl.ModelScopeChatCompletions): + """OpenRouter ChatCompletion API 请求器""" + + client: openai.AsyncClient + + default_config: dict[str, typing.Any] = { + 'base_url': 'https://openrouter.ai/api/v1', + 'timeout': 120, + } diff --git a/pkg/provider/modelmgr/requesters/openrouterchatcmpl.yaml b/pkg/provider/modelmgr/requesters/openrouterchatcmpl.yaml new file mode 100644 index 00000000..2ecee6cc --- /dev/null +++ b/pkg/provider/modelmgr/requesters/openrouterchatcmpl.yaml @@ -0,0 +1,28 @@ +apiVersion: v1 +kind: LLMAPIRequester +metadata: + name: openrouter-chat-completions + label: + en_US: OpenRouter + zh_Hans: OpenRouter + icon: openrouter.svg +spec: + config: + - name: base_url + label: + en_US: Base URL + zh_Hans: 基础 URL + type: string + required: true + default: "https://openrouter.ai/api/v1" + - name: timeout + label: + en_US: Timeout + zh_Hans: 超时时间 + type: integer + required: true + default: 120 +execution: + python: + path: ./openrouterchatcmpl.py + attr: OpenRouterChatCompletions