MCPcopy Create free account
hub / github.com/Louisym/MiniCC / _create_api_client

Function _create_api_client

mini_claude_code/main.py:693–716  ·  view source on GitHub ↗

尝试创建 API 客户端,注入工具定义。

(model: str)

Source from the content-addressed store, hash-verified

691
692
693def _create_api_client(model: str):
694 """尝试创建 API 客户端,注入工具定义。"""
695 try:
696 from mini_claude_code.api_client import ClaudeApiClient
697 api_key = os.environ.get("ANTHROPIC_API_KEY", "")
698 if not api_key:
699 print(
700 "error: ANTHROPIC_API_KEY not set. "
701 "Set it with: export ANTHROPIC_API_KEY=your-key",
702 file=sys.stderr,
703 )
704 return None
705 return ClaudeApiClient(
706 api_key=api_key,
707 model=model,
708 tools=DEFAULT_TOOL_DEFINITIONS,
709 )
710 except ImportError:
711 print(
712 "error: anthropic package not installed. "
713 "Install it with: pip install anthropic",
714 file=sys.stderr,
715 )
716 return None
717
718
719if __name__ == "__main__":

Callers 1

mainFunction · 0.85

Calls 2

ClaudeApiClientClass · 0.90
getMethod · 0.45

Tested by

no test coverage detected