ccproxy.services.claude_sdk_service¶
ccproxy.services.claude_sdk_service
¶
Claude SDK service orchestration for business logic.
ClaudeSDKService
¶
Service layer for Claude SDK operations orchestration.
This class handles business logic coordination between the pure SDK client, authentication, metrics, and format conversion while maintaining clean separation of concerns.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
sdk_client
|
ClaudeSDKClient | None
|
Claude SDK client instance |
None
|
auth_manager
|
AuthManager | None
|
Authentication manager (optional) |
None
|
metrics
|
PrometheusMetrics | None
|
Prometheus metrics instance (optional) |
None
|
settings
|
Settings | None
|
Application settings (optional) |
None
|
Source code in ccproxy/services/claude_sdk_service.py
create_completion
async
¶
create_completion(
messages,
model,
temperature=None,
max_tokens=None,
stream=False,
user_id=None,
**kwargs,
)
Create a completion using Claude SDK with business logic orchestration.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
messages
|
list[dict[str, Any]]
|
List of messages in Anthropic format |
required |
model
|
str
|
The model to use |
required |
temperature
|
float | None
|
Temperature for response generation |
None
|
max_tokens
|
int | None
|
Maximum tokens in response |
None
|
stream
|
bool
|
Whether to stream responses |
False
|
user_id
|
str | None
|
User identifier for auth/metrics |
None
|
**kwargs
|
Any
|
Additional arguments |
{}
|
Returns:
Type | Description |
---|---|
dict[str, Any] | AsyncIterator[dict[str, Any]]
|
Response dict or async iterator of response chunks if streaming |
Raises:
Type | Description |
---|---|
ClaudeProxyError
|
If request fails |
ServiceUnavailableError
|
If service is unavailable |
Source code in ccproxy/services/claude_sdk_service.py
66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 |
|
list_models
async
¶
List available Claude models and recent OpenAI models.
Returns:
Type | Description |
---|---|
dict[str, Any]
|
Dictionary with combined list of models in mixed format |
Source code in ccproxy/services/claude_sdk_service.py
473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 |
|
validate_health
async
¶
Validate that the service is healthy.
Returns:
Type | Description |
---|---|
bool
|
True if healthy, False otherwise |