summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorsigoden <sigoden@gmail.com>2024-10-23 07:46:59 +0800
committerGitHub <noreply@github.com>2024-10-23 07:46:59 +0800
commit8add4de77bee9e00a60e6c7f40276972cf3ea91f (patch)
treea220902243c715b6ff25b160abce71a0be2313d4
parentb82eb8969cd6b4d698b2636ac58f1bfe365e7893 (diff)
downloadaichat-8add4de77bee9e00a60e6c7f40276972cf3ea91f.tar.gz
feat: support xai (grok) client (#945)
-rwxr-xr-xArgcfile.sh1
-rw-r--r--config.example.yaml6
-rw-r--r--models.yaml11
-rw-r--r--src/client/mod.rs3
4 files changed, 20 insertions, 1 deletions
diff --git a/Argcfile.sh b/Argcfile.sh
index d36cd01..4cd53d8 100755
--- a/Argcfile.sh
+++ b/Argcfile.sh
@@ -97,6 +97,7 @@ OPENAI_COMPATIBLE_PLATFORMS=( \
qianwen,qwen-turbo,https://dashscope.aliyuncs.com/compatible-mode/v1 \
siliconflow,meta-llama/Meta-Llama-3.1-8B-Instruct,https://api.siliconflow.cn/v1 \
together,meta-llama/Meta-Llama-3.1-8B-Instruct-Turbo,https://api.together.xyz/v1 \
+ xai,grok-beta,https://api.x.ai/v1 \
zhipuai,glm-4-0520,https://open.bigmodel.cn/api/paas/v4 \
)
diff --git a/config.example.yaml b/config.example.yaml
index c46fbf0..6af2ee6 100644
--- a/config.example.yaml
+++ b/config.example.yaml
@@ -165,6 +165,12 @@ clients:
api_base: https://api.mistral.ai/v1
api_key: xxx
+ # See https://docs.x.ai/docs
+ - type: openai-compatible
+ name: xai
+ api_base: https://api.x.ai/v1
+ api_key: xxx
+
# See https://docs.ai21.com/docs/quickstart
- type: openai-compatible
name: ai12
diff --git a/models.yaml b/models.yaml
index 10c6592..4d7b452 100644
--- a/models.yaml
+++ b/models.yaml
@@ -278,6 +278,17 @@
max_input_tokens: 4096
# Links:
+# - https://docs.x.ai/docs#models
+# - https://cohere.com/pricing
+# - https://docs.x.ai/api/endpoints#chat-completions
+- platform: xai
+ models:
+ - name: grok-beta
+ max_input_tokens: 131072
+ input_price: 5
+ output_price: 10
+
+# Links:
# - https://docs.perplexity.ai/guides/model-cards
# - https://docs.perplexity.ai/guides/pricing
# - https://docs.perplexity.ai/api-reference/chat-completions
diff --git a/src/client/mod.rs b/src/client/mod.rs
index 24ced99..883d5f7 100644
--- a/src/client/mod.rs
+++ b/src/client/mod.rs
@@ -35,7 +35,7 @@ register_client!(
(ernie, "ernie", ErnieConfig, ErnieClient),
);
-pub const OPENAI_COMPATIBLE_PLATFORMS: [(&str, &str); 20] = [
+pub const OPENAI_COMPATIBLE_PLATFORMS: [(&str, &str); 21] = [
("ai21", "https://api.ai21.com/studio/v1"),
("cloudflare", ""),
("deepinfra", "https://api.deepinfra.com/v1/openai"),
@@ -56,6 +56,7 @@ pub const OPENAI_COMPATIBLE_PLATFORMS: [(&str, &str); 20] = [
),
("siliconflow", "https://api.siliconflow.cn/v1"),
("together", "https://api.together.xyz/v1"),
+ ("xai", "https://api.x.ai/v1"),
("zhipuai", "https://open.bigmodel.cn/api/paas/v4"),
// RAG-dedicated
("jina", "https://api.jina.ai/v1"),