EmailVerify LogoEmailVerify

AI SDKs

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

Создавайте ИИ-приложения со встроенными возможностями верификации email, используя популярные ИИ-фреймворки и SDK.

Поддерживаемые фреймворки

Сравнение

ФреймворкЯзыкЛучше всего дляСложность
Vercel AI SDKTypeScriptПриложений Next.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. Понятные описания инструментов

Пишите описательные определения инструментов, чтобы ИИ знал, когда их использовать:

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. Пакетная обработка для эффективности

При верификации нескольких email используйте bulk-эндпоинт:

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 hour

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