Skip to main content
This page makes reference to Groq, an AI hardware and software company. For information on how to use Grok models (provided by xAI), 请参阅 xAI provider page.
API 参考有关所有 features and configuration options, 请前往 ChatGroq API reference.
For a list of all Groq models, visit their docs.

概述

集成详情

模型功能

设置

要访问 Groq 模型,您需要创建一个 Groq 账户,获取 API 密钥,并安装 langchain-groq 集成包。

凭证

Head to the Groq console 注册 Groq 并生成 API 密钥。 完成后设置 GROQ_API_KEY 环境变量:
要启用模型调用的自动追踪,请设置您的 LangSmith API key:

安装

LangChain 的 Groq 集成位于 langchain-groq 包中:

实例化

Now we can instantiate our model object and generate chat completions.
Reasoning FormatIf you choose to set a reasoning_format, you must ensure that the model you are using supports it. You can find a list of supported models in the Groq documentation.

调用

Vision

Groq supports vision capabilities with select models, allowing you to send images along with text prompts.
Vision-capable models
  • meta-llama/llama-4-scout-17b-16e-instruct
  • meta-llama/llama-4-maverick-17b-128e-instruct
For the latest list of vision-capable models, check the Groq documentation.
Image URL requirementsGroq fetches images from URLs directly. Ensure your image URLs:
  • Are publicly accessible (no authentication required)
  • Return the image directly (no redirects)
  • Maximum image size: 20MB per request

API 参考

有关所有 ChatGroq 功能和配置的详细文档,请前往 API reference.