Skip to content

Commit

Permalink
feat: support xai (grok) client (#945)
Browse files Browse the repository at this point in the history
  • Loading branch information
sigoden authored Oct 22, 2024
1 parent b82eb89 commit 8add4de
Show file tree
Hide file tree
Showing 4 changed files with 20 additions and 1 deletion.
1 change: 1 addition & 0 deletions Argcfile.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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 \
)

Expand Down
6 changes: 6 additions & 0 deletions config.example.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
11 changes: 11 additions & 0 deletions models.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -277,6 +277,17 @@
type: reranker
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
Expand Down
3 changes: 2 additions & 1 deletion src/client/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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"),
Expand All @@ -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"),
Expand Down

0 comments on commit 8add4de

Please sign in to comment.