EmailVerify LogoEmailVerify

AI SDKs

Email checker integration with AI SDKs. Anthropic, OpenAI, LangChain, Vercel AI SDK guides.

인기 있는 AI 프레임워크와 SDK를 사용하여 내장된 이메일 검증 기능이 있는 AI 애플리케이션을 구축하세요.

지원되는 프레임워크

비교

프레임워크언어적합한 용도복잡도
Vercel AI SDKTypeScriptNext.js 앱, 스트리밍낮음
LangChainPython/JS복잡한 에이전트, 체인중간
OpenAI Functions모든 언어직접 GPT 통합중간
Anthropic Tools모든 언어직접 Claude 통합중간

빠른 예제

다음은 프레임워크 전반에서 작동하는 간단한 도구 정의입니다:

const verifyEmailTool = {
  name: 'verify_email',
  description: 'Verify if an email address is valid and deliverable',
  parameters: {
    type: 'object',
    properties: {
      email: {
        type: 'string',
        description: 'The email address to verify',
      },
    },
    required: ['email'],
  },
  execute: async ({ email }) => {
    const response = await fetch('https://api.emailverify.ai/v1/verify', {
      method: 'POST',
      headers: {
        'Authorization': `Bearer ${process.env.EMAILVERIFY_API_KEY}`,
        'Content-Type': 'application/json',
      },
      body: JSON.stringify({ email }),
    });
    return response.json();
  },
};

모범 사례

1. 오류 처리

도구에서 API 오류를 우아하게 처리하세요:

execute: async ({ email }) => {
  try {
    const response = await fetch('https://api.emailverify.ai/v1/verify', {
      method: 'POST',
      headers: {
        'Authorization': `Bearer ${process.env.EMAILVERIFY_API_KEY}`,
        'Content-Type': 'application/json',
      },
      body: JSON.stringify({ email }),
    });

    if (!response.ok) {
      if (response.status === 429) {
        return { error: 'Rate limit exceeded. Please try again later.' };
      }
      return { error: `Verification failed: ${response.statusText}` };
    }

    return response.json();
  } catch (error) {
    return { error: 'Network error. Could not reach verification service.' };
  }
}

2. 명확한 도구 설명

AI가 도구를 언제 사용해야 하는지 알 수 있도록 설명적인 도구 정의를 작성하세요:

description: `Verify if an email address is valid and deliverable.

Returns:
- status: "valid", "invalid", or "unknown"
- deliverable: whether the email can receive messages
- disposable: whether it's a temporary email service
- role: whether it's a role-based address like info@ or support@
- score: confidence score from 0 to 1

Use this tool when:
- User asks to verify an email
- Checking if an email is real
- Validating contact information`

3. 효율성을 위한 일괄 처리

여러 이메일을 검증할 때는 대량 엔드포인트를 사용하세요:

const verifyEmailsBulkTool = {
  name: 'verify_emails_bulk',
  description: 'Verify multiple emails at once. More efficient than verifying one by one.',
  parameters: {
    type: 'object',
    properties: {
      emails: {
        type: 'array',
        items: { type: 'string' },
        maxItems: 100,
      },
    },
    required: ['emails'],
  },
};

4. 결과 캐싱

크레딧을 절약하기 위해 검증 결과를 캐싱하는 것을 고려하세요:

const cache = new Map<string, { result: any; timestamp: number }>();
const CACHE_TTL = 3600000; // 1시간

async function verifyWithCache(email: string) {
  const cached = cache.get(email);
  if (cached && Date.now() - cached.timestamp < CACHE_TTL) {
    return cached.result;
  }

  const result = await verifyEmail(email);
  cache.set(email, { result, timestamp: Date.now() });
  return result;
}

다음 단계

On this page