Skip to content

Conversation

Copy link

Copilot AI commented Jan 22, 2026

Description

Implements Anthropic provider for TypeScript per blueprint/providers/anthropic.md. Converts OpenAI-compatible API to Anthropic's message format with full support for tool calling and streaming.

Changes

  • ts/src/providers/anthropic.ts: New provider implementing all blueprint conversions:

    • System messages extracted to system parameter
    • Tool messages → tool_result blocks in user messages
    • Tool calls → tool_use blocks
    • Image URLs (base64 and regular)
    • Tool choice/spec conversion ("required""any", etc.)
    • parallel_tool_calls inverted to disable_parallel_tool_use
    • Stop reason mapping (end_turnstop, tool_usetool_calls)
    • Default max_tokens: 8192
    • response_format rejection with guidance
    • Error mapping to AnyLLM error types
  • ts/src/any_llm.ts: Register "anthropic" in factory

  • ts/src/index.ts: Export AnthropicProvider

  • ts/tests/integration.test.ts: Parallel tool calls agent loop test

Usage

const llm = await AnyLLM.create("anthropic", ANTHROPIC_API_KEY);
const result = await llm.completion("claude-haiku-4-5-20251001", messages, { tools });

PR Type

  • 🆕 New Feature

Relevant issues

Fixes #6

Checklist

  • I understand the code I am submitting.
  • I have added unit tests that prove my fix/feature works
  • I have run this code locally and verified it fixes the issue.
  • New and existing tests pass locally
  • Documentation was updated where necessary
  • I have read and followed the contribution guidelines
  • AI Usage:
    • No AI was used.
    • AI was used for drafting/refactoring.
    • This is fully AI-generated.

AI Usage Information

  • AI Model used: Claude Sonnet 4
  • AI Developer Tool used: GitHub Copilot Coding Agent
  • Any other info you'd like to share: Implementation follows Python provider as reference

When answering questions by the reviewer, please respond yourself, do not copy/paste the reviewer comments into an AI system and paste back its answer. We want to discuss with you, not your AI :)

Original prompt

This section details on the original issue you should resolve

<issue_title>[Generation]: Anthropic support in TypeScript</issue_title>
<issue_description>Implement the feature described in blueprint/providers/anthropic.md for TypeScript.

Put the output in ts/providers/anthropic.ts.

Update integration tests to run against Anthropic API and make sure they pass.</issue_description>

Comments on the Issue (you are @copilot in this section)


💡 You can make Copilot smarter by setting up custom instructions, customizing its development environment and configuring Model Context Protocol (MCP) servers. Learn more Copilot coding agent tips in the docs.

Copilot AI changed the title [WIP] Add Anthropic support for TypeScript integration [Generation]: Anthropic support in TypeScript Jan 22, 2026
Copilot AI requested a review from daavoo January 22, 2026 16:12
@daavoo daavoo marked this pull request as ready for review January 22, 2026 18:44
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants