跳转到主要内容

Groq 的工作原理

Groq Cloud 提供快速的 LLM 推理和兼容 OpenAI 的 API。专为速度和简洁性而构建,Groq 为流行模型(如 Llama、Deepseek 等)提供超快速推理。该平台设计简单易集成且易于扩展,非常适合生产应用。

推荐模型

我们推荐具有高上下文窗口和快速推理的优秀编码模型。
如需最新信息,请访问 Groq 的模型页面
模型上下文窗口速度
Llama 3.3 70B Versatile 推荐~128k 令牌超快速
Deepseek R1 Distill Llama 70B~128k 令牌超快速
Llama 3.1 70B Versatile~128k 令牌超快速

创建 API 密钥

需要 Groq Cloud 账户才能创建 API 密钥。
直接访问 Groq 的 API 密钥页面创建新的 API 密钥。 或者,按照以下步骤操作:
  1. 访问 Groq 控制台
  2. 登录或创建您的账户
  3. 在顶部导航中导航到”API Keys”
  4. 点击”Create API Key”按钮
  5. 为其命名,例如’Kodus’或任何描述性名称
  6. 复制 API 密钥并将其保存在安全的地方
在 Groq 中,只有团队所有者或具有开发者角色的用户可以创建或管理 API 密钥。

如何使用

System Requirements

  • Docker (latest stable version) - Node.js (latest LTS version) - Yarn or NPM (latest stable version) - Domain name or fixed IP (for external deployments)
  • 3000: Kodus Web App - 3001: Orchestrator API - 5672, 15672: RabbitMQ - 5432: PostgreSQL - 27017: MongoDB
Internet access is only required if you plan to connect with cloud-based Git services like GitHub, GitLab, or Bitbucket. For self-hosted Git tools within your network, external internet access is optional.

Domain Name Setup (Optional)

If you're planning to integrate Kodus with cloud-based Git providers (GitHub, GitLab, or Bitbucket), you'll need public-facing URLs for both the Kodus Web App and its API. This allows your server to receive webhooks for proper Code Review functionality and ensures correct application behavior. We recommend setting up two subdomains:
  • One for the Web Application, e.g., kodus-web.yourdomain.com.
  • One for the API, e.g., kodus-api.yourdomain.com.
Both subdomains should have DNS A records pointing to your server's IP address. Later in this guide, we will configure a reverse proxy (Nginx) to route requests to these subdomains to the correct internal services. This setup is essential for full functionality, including webhooks and authentication.
Note: If you're only connecting to self-hosted Git tools on your network and do not require public access or webhooks, you might be able to use a simpler setup, but this guide focuses on public-facing deployments.

Get the Kodus Installer

Clone our installer repository:
git clone https://github.com/kodustech/kodus-installer.git
cd kodus-installer

Configure Environment Variables

First, copy the example environment file:
cp .env.example .env
Generate secure keys for the required environment variables using:
# For most security keys
openssl rand -base64 32

# Specifically for API_CRYPTO_KEY and CODE_MANAGEMENT_SECRET
openssl rand -hex 32

# Specifically for CODE_MANAGEMENT_WEBHOOK_TOKEN
openssl rand -base64 32 | tr -d '=' | tr '/+' '_-'
You'll need to generate values for these security keys:
  • WEB_NEXTAUTH_SECRET (use openssl rand -base64 32)
  • WEB_JWT_SECRET_KEY (use openssl rand -base64 32)
  • API_CRYPTO_KEY (use openssl rand -hex 32)
  • API_JWT_SECRET (use openssl rand -base64 32)
  • API_JWT_REFRESHSECRET (use openssl rand -base64 32)
  • CODE_MANAGEMENT_SECRET (use openssl rand -hex 32)
  • CODE_MANAGEMENT_WEBHOOK_TOKEN (use openssl rand -base64 32 | tr -d '=' | tr '/+' '_-')
Never commit your .env file to version control. Keep your API keys and database credentials secure.
Then update your .env file with the following required variables:
# Core System Settings
WEB_NODE_ENV="self-hosted"                     # Keep as "self-hosted" for self-hosted setup
WEB_HOSTNAME_API="kodus-api.yourdomain.com"    # Public API hostname (e.g., kodus-api.yourdomain.com)
WEB_PORT_API=443                               # Public API port (usually 443 for HTTPS, or 80 if not using SSL yet)
WEB_PORT=3000                                  # Internal Web application port (reverse proxy will handle public port)
GLOBAL_API_CONTAINER_NAME="kodus-orchestrator" # API container name

# Authentication Settings
NEXTAUTH_URL="https://kodus-web.yourdomain.com" # Full public base URL for the Web App (e.g., https://kodus-web.yourdomain.com)
WEB_NEXTAUTH_SECRET=""                        # NextAuth secret key (generate with: openssl rand -base64 32)
WEB_JWT_SECRET_KEY=""                         # JWT secret key (generate with: openssl rand -base64 32)

# API Configuration
API_NODE_ENV="development"                    # Keep as "development" for local setup
API_LOG_LEVEL=error                           # Error logging level
API_LOG_PRETTY=true                           # Pretty print logs
API_HOST=0.0.0.0                              # API host
API_PORT=3001                                 # API port
API_RATE_MAX_REQUEST=100                      # Rate limiting: max requests
API_RATE_INTERVAL=1000                        # Rate limiting: time window (ms)
API_CRYPTO_KEY=                               # Crypto key (generate with: openssl rand -hex 32)
API_JWT_EXPIRES_IN=365d                       # JWT token expiration time
API_JWT_SECRET=                               # JWT secret key
API_JWT_REFRESHSECRET=                        # JWT refresh token secret key
API_JWT_REFRESH_EXPIRES_IN=7d                 # JWT refresh token expiration time

# Database Configuration
API_DATABASE_ENV="development"                # Database environment
API_PG_DB_HOST=db_kodus_postgres              # PostgreSQL host
API_PG_DB_PORT=5432                          # PostgreSQL port
API_PG_DB_USERNAME=kodusdev                  # Database username
API_PG_DB_PASSWORD=                          # Database password
API_PG_DB_DATABASE=kodus_db                  # Database name

# MongoDB Configuration
API_MG_DB_HOST=db_kodus_mongodb              # MongoDB host
API_MG_DB_PORT=27017                         # MongoDB port
API_MG_DB_USERNAME=kodusdev                  # Database username
API_MG_DB_PASSWORD=                          # Database password
API_MG_DB_DATABASE=kodus_db                  # Database name

在环境文件中配置 Groq

编辑您的 .env 文件并配置核心设置。对于 LLM 集成,在固定模式下使用 Groq:
# 核心系统设置(使用您的域名更新)
WEB_HOSTNAME_API="kodus-api.yourdomain.com"
WEB_PORT_API=443
NEXTAUTH_URL="https://kodus-web.yourdomain.com"

# 安全密钥(使用上面的 openssl 命令生成)
WEB_NEXTAUTH_SECRET="your-generated-secret"
WEB_JWT_SECRET_KEY="your-generated-secret"
API_CRYPTO_KEY="your-generated-hex-key"
API_JWT_SECRET="your-generated-secret"
API_JWT_REFRESHSECRET="your-generated-secret"

# 数据库配置
API_PG_DB_PASSWORD="your-secure-db-password"
API_MG_DB_PASSWORD="your-secure-db-password"

# Groq 配置(固定模式)
API_LLM_PROVIDER_MODEL="llama-3.3-70b-versatile"             # 选择您偏好的模型
API_OPENAI_FORCE_BASE_URL="https://api.groq.com/openai/v1"   # Groq API URL
API_OPEN_AI_API_KEY="your-groq-api-key"                      # 您的 Groq API 密钥

# Git 提供商 Webhook(选择您的提供商)
API_GITHUB_CODE_MANAGEMENT_WEBHOOK="https://kodus-api.yourdomain.com/github/webhook"
# 或 API_GITLAB_CODE_MANAGEMENT_WEBHOOK="https://kodus-api.yourdomain.com/gitlab/webhook"
# 或 GLOBAL_BITBUCKET_CODE_MANAGEMENT_WEBHOOK="https://kodus-api.yourdomain.com/bitbucket/webhook"
固定模式非常适合 Groq,因为它提供兼容 OpenAI 的 API 和超快速推理。这为您提供了最佳性能和简单配置。

Run the Installation Script

Looking for more control? Check out our docker-compose file for manual deployment options.
Set the proper permissions for the installation script:
chmod +x scripts/install.sh
Run the script:
./scripts/install.sh

What the Installer Does

Our installer automates several important steps:
  • Verifies Docker installation
  • Creates networks for Kodus services
  • Clones repositories and configures environment files
  • Runs docker-compose to start all services
  • Executes database migrations
  • Seeds initial data
🎉 Success! When complete, Kodus Orchestrator API and Web Application should be running on your machine. You can verify your installation by visiting http://localhost:3000 - you should see the Kodus Web Application interface.
Code Review features will not work yet unless you complete the reverse proxy setup. Without this configuration, external Git providers cannot send webhooks to your instance.

设置反向代理(用于生产环境)

对于 Webhook 和外部访问,配置 Nginx:
# Web 应用(端口 3000)
server {
    listen 80;
    server_name kodus-web.yourdomain.com;
    location / {
        proxy_pass http://localhost:3000;
        proxy_set_header Host $host;
        proxy_set_header X-Real-IP $remote_addr;
        proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
        proxy_set_header X-Forwarded-Proto $scheme;
    }
}

# API(端口 3001)
server {
    listen 80;
    server_name kodus-api.yourdomain.com;
    location / {
        proxy_pass http://localhost:3001;
        proxy_set_header Host $host;
        proxy_set_header X-Real-IP $remote_addr;
        proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
        proxy_set_header X-Forwarded-Proto $scheme;
    }
}

验证 Groq 集成

除了基本的安装验证外,确认 Groq 正常工作:
# 专门验证 Groq API 连接
docker logs kodus-orchestrator-prod | grep -i groq
有关 SSL 设置、监控和高级配置的详细信息,请参阅我们的完整部署指南

故障排除

  • Groq 控制台中验证您的 API 密钥是否正确且处于活动状态
  • 检查您的 Groq 账户中是否有足够的信用额度或配额
  • 确保您的 .env 文件中没有多余的空格
  • 检查配置中的模型名称拼写是否正确
  • 验证该模型在 Groq 当前的模型列表中是否可用
  • 尝试使用我们推荐列表中的其他模型
  • 验证您的服务器是否有互联网访问权限以访问 api.groq.com
  • 检查是否有任何防火墙限制
  • 查看编排器日志以获取详细的错误消息
  • Groq 根据您的计划有速率限制
  • 查看 Groq 速率限制文档
  • 考虑升级您的计划以获得更高的限制