exa-deploy-integration

Compare original and translation side by side

🇺🇸

Original

English
🇨🇳

Translation

Chinese

Exa Deploy Integration

Exa 部署集成

Overview

概述

Deploy Exa-powered applications to popular platforms with proper secrets management.
将基于Exa的应用部署至主流平台,并妥善管理密钥。

Prerequisites

前提条件

  • Exa API keys for production environment
  • Platform CLI installed (vercel, fly, or gcloud)
  • Application code ready for deployment
  • Environment variables documented
  • 生产环境的Exa API密钥
  • 已安装平台CLI(vercel、fly或gcloud)
  • 应用代码已准备好部署
  • 环境变量已整理归档

Vercel Deployment

Vercel 部署

Environment Setup

环境配置

bash
undefined
bash
undefined

Add Exa secrets to Vercel

Add Exa secrets to Vercel

vercel secrets add exa_api_key sk_live_*** vercel secrets add exa_webhook_secret whsec_***
vercel secrets add exa_api_key sk_live_*** vercel secrets add exa_webhook_secret whsec_***

Link to project

Link to project

vercel link
vercel link

Deploy preview

Deploy preview

vercel
vercel

Deploy production

Deploy production

vercel --prod
undefined
vercel --prod
undefined

vercel.json Configuration

vercel.json 配置

json
{
  "env": {
    "EXA_API_KEY": "@exa_api_key"
  },
  "functions": {
    "api/**/*.ts": {
      "maxDuration": 30
    }
  }
}
json
{
  "env": {
    "EXA_API_KEY": "@exa_api_key"
  },
  "functions": {
    "api/**/*.ts": {
      "maxDuration": 30
    }
  }
}

Fly.io Deployment

Fly.io 部署

fly.toml

fly.toml

toml
app = "my-exa-app"
primary_region = "iad"

[env]
  NODE_ENV = "production"

[http_service]
  internal_port = 3000
  force_https = true
  auto_stop_machines = true
  auto_start_machines = true
toml
app = "my-exa-app"
primary_region = "iad"

[env]
  NODE_ENV = "production"

[http_service]
  internal_port = 3000
  force_https = true
  auto_stop_machines = true
  auto_start_machines = true

Secrets

密钥配置

bash
undefined
bash
undefined

Set Exa secrets

Set Exa secrets

fly secrets set EXA_API_KEY=sk_live_*** fly secrets set EXA_WEBHOOK_SECRET=whsec_***
fly secrets set EXA_API_KEY=sk_live_*** fly secrets set EXA_WEBHOOK_SECRET=whsec_***

Deploy

Deploy

fly deploy
undefined
fly deploy
undefined

Google Cloud Run

Google Cloud Run 部署

Dockerfile

Dockerfile

dockerfile
FROM node:20-slim
WORKDIR /app
COPY package*.json ./
RUN npm ci --only=production
COPY . .
CMD ["npm", "start"]
dockerfile
FROM node:20-slim
WORKDIR /app
COPY package*.json ./
RUN npm ci --only=production
COPY . .
CMD ["npm", "start"]

Deploy Script

部署脚本

bash
#!/bin/bash
bash
#!/bin/bash

deploy-cloud-run.sh

deploy-cloud-run.sh

PROJECT_ID="${GOOGLE_CLOUD_PROJECT}" SERVICE_NAME="exa-service" REGION="us-central1"
PROJECT_ID="${GOOGLE_CLOUD_PROJECT}" SERVICE_NAME="exa-service" REGION="us-central1"

Build and push image

Build and push image

gcloud builds submit --tag gcr.io/$PROJECT_ID/$SERVICE_NAME
gcloud builds submit --tag gcr.io/$PROJECT_ID/$SERVICE_NAME

Deploy to Cloud Run

Deploy to Cloud Run

gcloud run deploy $SERVICE_NAME
--image gcr.io/$PROJECT_ID/$SERVICE_NAME
--region $REGION
--platform managed
--allow-unauthenticated
--set-secrets=EXA_API_KEY=exa-api-key:latest
undefined
gcloud run deploy $SERVICE_NAME
--image gcr.io/$PROJECT_ID/$SERVICE_NAME
--region $REGION
--platform managed
--allow-unauthenticated
--set-secrets=EXA_API_KEY=exa-api-key:latest
undefined

Environment Configuration Pattern

环境配置模式

typescript
// config/exa.ts
interface ExaConfig {
  apiKey: string;
  environment: 'development' | 'staging' | 'production';
  webhookSecret?: string;
}

export function getExaConfig(): ExaConfig {
  const env = process.env.NODE_ENV || 'development';

  return {
    apiKey: process.env.EXA_API_KEY!,
    environment: env as ExaConfig['environment'],
    webhookSecret: process.env.EXA_WEBHOOK_SECRET,
  };
}
typescript
// config/exa.ts
interface ExaConfig {
  apiKey: string;
  environment: 'development' | 'staging' | 'production';
  webhookSecret?: string;
}

export function getExaConfig(): ExaConfig {
  const env = process.env.NODE_ENV || 'development';

  return {
    apiKey: process.env.EXA_API_KEY!,
    environment: env as ExaConfig['environment'],
    webhookSecret: process.env.EXA_WEBHOOK_SECRET,
  };
}

Health Check Endpoint

健康检查端点

typescript
// api/health.ts
export async function GET() {
  const exaStatus = await checkExaConnection();

  return Response.json({
    status: exaStatus ? 'healthy' : 'degraded',
    services: {
      exa: exaStatus,
    },
    timestamp: new Date().toISOString(),
  });
}
typescript
// api/health.ts
export async function GET() {
  const exaStatus = await checkExaConnection();

  return Response.json({
    status: exaStatus ? 'healthy' : 'degraded',
    services: {
      exa: exaStatus,
    },
    timestamp: new Date().toISOString(),
  });
}

Instructions

操作步骤

Step 1: Choose Deployment Platform

步骤1:选择部署平台

Select the platform that best fits your infrastructure needs and follow the platform-specific guide below.
根据基础设施需求选择合适的平台,然后遵循下方对应平台的指南操作。

Step 2: Configure Secrets

步骤2:配置密钥

Store Exa API keys securely using the platform's secrets management.
使用平台的密钥管理功能安全存储Exa API密钥。

Step 3: Deploy Application

步骤3:部署应用

Use the platform CLI to deploy your application with Exa integration.
使用平台CLI部署集成了Exa的应用。

Step 4: Verify Health

步骤4:验证健康状态

Test the health check endpoint to confirm Exa connectivity.
测试健康检查端点,确认与Exa的连接正常。

Output

输出结果

  • Application deployed to production
  • Exa secrets securely configured
  • Health check endpoint functional
  • Environment-specific configuration in place
  • 应用已部署至生产环境
  • Exa密钥已安全配置
  • 健康检查端点正常运行
  • 已配置环境专属的配置项

Error Handling

错误处理

IssueCauseSolution
Secret not foundMissing configurationAdd secret via platform CLI
Deploy timeoutLarge buildIncrease build timeout
Health check failsWrong API keyVerify environment variable
Cold start issuesNo warm-upConfigure minimum instances
问题原因解决方案
密钥未找到配置缺失通过平台CLI添加密钥
部署超时构建包过大延长构建超时时间
健康检查失败API密钥错误验证环境变量
冷启动问题无预热配置配置最小实例数

Examples

示例

Quick Deploy Script

快速部署脚本

bash
#!/bin/bash
bash
#!/bin/bash

Platform-agnostic deploy helper

Platform-agnostic deploy helper

case "$1" in vercel) vercel secrets add exa_api_key "$EXA_API_KEY" vercel --prod ;; fly) fly secrets set EXA_API_KEY="$EXA_API_KEY" fly deploy ;; esac
undefined
case "$1" in vercel) vercel secrets add exa_api_key "$EXA_API_KEY" vercel --prod ;; fly) fly secrets set EXA_API_KEY="$EXA_API_KEY" fly deploy ;; esac
undefined

Resources

参考资源

Next Steps

后续步骤

For webhook handling, see
exa-webhooks-events
.
如需处理Webhook,请查看
exa-webhooks-events