Feat: add xAI provider (#8781)

### What problem does this PR solve?

Add xAI provider (experimental feature, requires user feedback).

### Type of change

- [x] New Feature (non-breaking change which adds functionality)
This commit is contained in:
Yongteng Lei
2025-07-11 10:35:23 +08:00
committed by GitHub
parent fc0c81acc6
commit 1895667573
4 changed files with 76 additions and 0 deletions

View File

@ -568,6 +568,16 @@ class BaiChuanChat(Base):
yield total_tokens
class xAIChat(Base):
_FACTORY_NAME = "xAI"
def __init__(self, key, model_name="grok-3", base_url=None, **kwargs):
if not base_url:
base_url = "https://api.x.ai/v1"
super().__init__(key, model_name, base_url=base_url, **kwargs)
return
class QWenChat(Base):
_FACTORY_NAME = "Tongyi-Qianwen"

View File

@ -223,6 +223,16 @@ class AzureGptV4(Base):
return res.choices[0].message.content.strip(), res.usage.total_tokens
class xAICV(Base):
_FACTORY_NAME = "xAI"
def __init__(self, key, model_name="grok-3", base_url=None, **kwargs):
if not base_url:
base_url = "https://api.x.ai/v1"
super().__init__(key, model_name, base_url=base_url, **kwargs)
return
class QWenCV(Base):
_FACTORY_NAME = "Tongyi-Qianwen"