文本对话系列Grok 系列
Grok 4.20 Fast
xAI Grok 4.20 Fast · 实时对话、推理
该模型已下线:CokeAPI 当前价目表中已不再提供 grok-4.20-fast,调用会返回模型不存在错误。请迁移到 gpt-5.5。本页仅作历史参考。
Grok 4.20 Fast 是 xAI 提供的高速文本对话模型,适合实时对话与推理任务。上下文窗口 256K。
调用示例
curl https://cokeapi.com/v1/chat/completions \
-H "Authorization: Bearer sk-xxxxxxxx" \
-H "Content-Type: application/json" \
-d '{
"model": "grok-4.20-fast",
"messages": [{"role": "user", "content": "你好"}]
}'from openai import OpenAI
client = OpenAI(base_url="https://cokeapi.com/v1", api_key="sk-xxxxxxxx")
resp = client.chat.completions.create(
model="grok-4.20-fast",
messages=[{"role": "user", "content": "你好"}],
)
print(resp.choices[0].message.content)import OpenAI from 'openai';
const client = new OpenAI({ baseURL: 'https://cokeapi.com/v1', apiKey: 'sk-xxxxxxxx' });
const resp = await client.chat.completions.create({
model: 'grok-4.20-fast',
messages: [{ role: 'user', content: '你好' }],
});
console.log(resp.choices[0].message.content);package main
import (
"context"
"fmt"
openai "github.com/sashabaranov/go-openai"
)
func main() {
client := openai.NewClient("sk-xxxxxxxx")
resp, err := client.CreateChatCompletion(
context.Background(),
openai.ChatCompletionRequest{
Model: "grok-4.20-fast",
Messages: []openai.ChatCompletionMessage{
{Role: openai.ChatMessageRoleUser, Content: "你好"},
},
},
)
if err != nil {
fmt.Println(err)
return
}
fmt.Println(resp.Choices[0].Message.Content)
}import com.openai.client.OpenAIClient;
import com.openai.client.okhttp.OpenAIOkHttpClient;
import com.openai.models.ChatCompletion;
import com.openai.models.ChatCompletionCreateParams;
import com.openai.models.ChatCompletionMessageParam;
public class Main {
public static void main(String[] args) {
OpenAIClient client = OpenAIOkHttpClient.builder()
.apiKey("sk-xxxxxxxx")
.baseUrl("https://cokeapi.com/v1")
.build();
ChatCompletionCreateParams params = ChatCompletionCreateParams.builder()
.addMessage(ChatCompletionMessageParam.ofUser("你好"))
.model("grok-4.20-fast")
.build();
ChatCompletion chatCompletion = client.chat().completions().create(params);
System.out.println(chatCompletion.choices().get(0).message().content());
}
}