Provider-Agnostic LLM Client Adapter for OpenAI, Claude, and Gemini

Have Codex build a thin, config-driven client that normalizes requests, responses, errors, and token usage across several model providers, so switching models becomes a config change instead of a rewrite.

You getFindings table, implementation summary with file paths changed and provider mapping table

The prompt

Prompt
Role: You are a senior backend engineer working inside Codex. You specialize in provider-agnostic LLM clients and know the differences between the OpenAI Responses and Chat APIs, Anthropic Messages, Google Gemini generateContent, Mistral, and OpenAI-compatible endpoints used for Llama and DeepSeek.

Context: Our team needs one Python 3.11 (example value for {language}) client that can call OpenAI, Anthropic Claude, Google Gemini (example value for {providers}) for the use case: summarizing customer support tickets into short action items (example value for {use_case}). The decision this code must support is whether we can swap or add a model by editing config only. Runtime environment: FastAPI service running in Docker on Linux (example value for {runtime}).

Task: Inspect the existing repository first, then design and implement a small adapter layer plus tests. State assumptions separately from facts you verified in the repo. Do not claim any live API call succeeded unless you actually ran it; otherwise mock the provider responses.

Inputs:
- Language and runtime: Python 3.11 (example value for {language}), FastAPI service running in Docker on Linux (example value for {runtime})
- Providers to support: OpenAI, Anthropic Claude, Google Gemini (example value for {providers})
- Use case: summarizing customer support tickets into short action items (example value for {use_case})
- Per-request timeout in seconds: 30 (example value for {timeout_seconds})
- Credentials are read only from environment variables; never hardcode keys or log them.

Workflow:
1. Scan the repo for existing HTTP, config, and test conventions and list what you found.
2. List missing information and the assumptions you will make for each gap.
3. Define one normalized request type (system prompt, messages, temperature, max output tokens, optional JSON schema) and one normalized response type (text, finish reason, input tokens, output tokens, provider, model, latency in ms, raw payload reference).
4. Implement one adapter per provider that maps the normalized request to the provider format. Note provider-specific details: system prompt placement, role names, max token parameter names, and safety or stop reasons.
5. Add a shared error taxonomy (auth, rate limit, timeout, invalid request, content blocked, server error) with retry and exponential backoff for rate limit and server errors only.
6. Add a config file mapping logical model aliases to provider and model IDs, with a fallback order.
7. Write unit tests using mocked HTTP responses, including one failure case per error type.
8. Run the tests and report the exact results.

Constraints:
- Use the fewest dependencies possible and prefer official SDKs only if the repo already uses them.
- Keep model IDs in config, not in code.
- Do not add telemetry or send data anywhere except the configured provider endpoints.

Output format:
1. Findings table: file, observation, impact.
2. Assumptions list.
3. Implementation summary with file paths changed.
4. Provider mapping table: normalized field, provider field, notes.
5. Test results as pass or fail counts plus any failures.
6. Risks and missing information.
7. Next actions as a prioritized checklist.

Acceptance criteria:
- Adding a new model alias requires only a config edit.
- All adapters return the same normalized response shape.
- Retries occur only for retryable errors and are capped.
- Tests pass locally without network access or real keys.

Quality checks:
- No secrets appear in code, logs, or test fixtures.
- Every provider difference you relied on is listed in the mapping table.
- Anything you could not verify is labeled as an assumption.
- The final answer states which parts were run and which were only written.

Dashed parts are example values, so the prompt runs as copied. Change them in Fill in the blanks.

Run in Codex from the repository root. Verify provider parameter names against each vendor's current docs before shipping, since APIs change. Use mocked tests first and add a gated live smoke test only with your own keys.

Keep exploring

More in Major AI Models