AI Provider Integration
Relevant source files
The following files were used as context for generating this wiki page:The GUC Resume Enhancer integrates with multiple third-party AI providers to offer a range of resume optimization features. This system is designed to be flexible, allowing users to manage their own API keys and select from various AI models to process their resumes. The core functionality revolves around sending resume content to an AI service and then storing the enhanced version.
The integration supports OpenAI, Anthropic (Claude), and Google (Gemini) as AI providers. Users can configure their keys through a dedicated management interface, and the system will use the active key for all enhancement tasks. This multi-provider approach ensures users can leverage the strengths of different Large Language Models (LLMs) for their specific needs.
Sources: README.md:10, api/enhance-resume/[id]/route.ts:240-251, api-keys/_components/api-key-manager.tsx:40-58
Architecture Overview
The AI integration architecture involves the frontend client, the application's backend API, the database for storing keys and results, and the external AI provider APIs. The user initiates an enhancement from the web interface, which triggers a backend process to securely call the selected AI provider and update the database with the result.
The following diagram illustrates the high-level data flow for an AI enhancement request.
This diagram shows the flow from user action to external API call and final storage.
Sources: enhance/[id]/_components/enhance-interface.tsx:210-231, api/enhance-resume/[id]/route.ts:182-278, schema.prisma:108-121
Supported Providers and Models
The application supports three major AI providers. Users can select a default model for each provider key they add.
| Provider | Supported Models |
|---|---|
| OpenAI | gpt-4o, gpt-4o-mini, gpt-4-turbo |
| Anthropic | claude-3-5-sonnet, claude-3-opus, claude-3-sonnet |
| Google Gemini | gemini-1.5-pro, gemini-1.5-flash |
Sources: README.md:104-118, INTEGRATION_GUIDE.md:20
API Key Management
Users must configure their own API keys to use the AI enhancement features. The system provides two modes for key management: a full mode with database-backed storage for authenticated users, and a "light mode" that uses browser localStorage.
Key Storage
In the full, authenticated mode, user-provided API keys are encrypted and stored in the UserApiKey table in the database. Each key is associated with a user, a provider, a user-defined name, and a default model. Only one key can be isActive at a time.
The diagram below shows the relationship between the User and UserApiKey tables.
Key Management UI
The API Key Manager, found at /api-keys, allows users to:
- Add a new API key for a supported provider (OpenAI, Anthropic, Gemini).
- Select a default model for that key from a list of available models.
- View all their configured keys.
- Delete existing keys.
The "Light Mode" at /api-keys-light provides similar functionality but stores keys in the browser's local storage, meaning they are not persistent across devices.
Sources: api-keys/_components/api-key-manager.tsx, api-keys-light/page.tsx
Resume Enhancement Workflow
The enhancement process is initiated from the enhancement interface for a specific resume. The workflow is executed by the POST /api/enhance-resume/[id] endpoint.
The following sequence diagram details the interactions between the client, backend, database, and external AI services.
This diagram shows the end-to-end flow for enhancing a resume.
Sources: api/enhance-resume/[id]/route.ts:182-278, enhance/[id]/_components/enhance-interface.tsx:210-231
Provider-Specific Logic
The backend contains helper functions for each AI provider, which format the request according to the provider's specific API requirements.
enhanceWithOpenAI: Callshttps://api.openai.com/v1/chat/completions.enhanceWithAnthropic: Callshttps://api.anthropic.com/v1/messages.enhanceWithGemini: Callshttps://generativelanguage.googleapis.com/v1beta/models/{model}:generateContent.
Each function uses a specific prompt tailored to the enhancementType requested by the user.
Sources: api/enhance-resume/[id]/route.ts:13-152
Enhancement Types
Users can choose from several enhancement types, each with a specific goal. These types correspond to different prompts sent to the AI.
| Enhancement Type Value | Label | Description |
|---|---|---|
skills_certifications | Skills & Certifications | Highlight trade skills, licenses, and certifications. |
project_experience | Project Experience | Showcase completed work and technical expertise. |
client_quality | Client Success & Quality | Emphasize customer satisfaction and quality work. |
Sources: enhance/[id]/_components/enhance-interface.tsx:71-91, api/enhance-resume/[id]/route.ts:14-17
API Endpoint: POST /api/enhance-resume/[id]
This endpoint triggers the AI enhancement for a given resume.
- URL:
/api/enhance-resume/:id - Method:
POST - Authentication: Required (NextAuth session)
Request Body:
{
"enhancementType": "string"
}
| Parameter | Type | Description | Required |
|---|---|---|---|
enhancementType | string | The type of enhancement to perform. Must be one of skills_certifications, project_experience, or client_quality. | Yes |
Responses:
200 OK: Successful enhancement.{ "success": true, "enhancement": { "id": "string", "resumeId": "string", "enhancementType": "string", "enhancedContent": "string", "llmProvider": "string", "status": "completed", // ... other fields } }400 Bad Request: Missing or invalidenhancementType, or no active API key found.401 Unauthorized: User is not authenticated.404 Not Found: Resume with the giveniddoes not exist for the user.500 Internal Server Error: The AI provider API call failed or another server-side error occurred.
Sources: api/enhance-resume/[id]/route.ts:182-286
Summary
The AI Provider Integration is a cornerstone of the GUC Resume Enhancer, providing the core value proposition of AI-powered resume optimization. It is built to be modular, supporting multiple LLM providers through a unified backend workflow. By allowing users to manage their own API keys, the system offers flexibility while offloading the cost of AI API calls to the end-user. The entire process, from key management to the final enhancement, is designed with security and user control in mind.
Sources: README.md:10-12, api-keys/_components/api-key-manager.tsx