Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: add xai (grok) client #945

Merged
merged 1 commit into from
Oct 22, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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