Ana içeriğe atla

Genel Bakış

LemonData, doğal Anthropic Messages API yolunu destekler; böylece Claude modelleri için resmi Anthropic SDK’yı doğrudan kullanabilirsiniz.
Anthropic SDK için base URL olarak https://api.lemondata.cc kullanın; /v1 ekini kendiniz eklemeyin.
Tür: Native SDKBirincil yol: Anthropic-nativeDestek seviyesi: Güçlü native path
Among the documented SDK routes, this is one of the strongest-supported LemonData paths for Claude-native features.

Kurulum

pip install anthropic

Client’ı Yapılandırın

from anthropic import Anthropic

client = Anthropic(
    api_key="sk-your-lemondata-key",
    base_url="https://api.lemondata.cc",
)

Temel Kullanım

message = client.messages.create(
    model="claude-sonnet-4-6",
    max_tokens=1024,
    messages=[
        {"role": "user", "content": "Explain LemonData in one sentence."}
    ]
)

print(message.content[0].text)

Streaming

with client.messages.stream(
    model="claude-sonnet-4-6",
    max_tokens=1024,
    messages=[{"role": "user", "content": "Write a short poem about coding."}]
) as stream:
    for text in stream.text_stream:
        print(text, end="", flush=True)

Vision

import base64

message = client.messages.create(
    model="claude-sonnet-4-6",
    max_tokens=1024,
    messages=[{
        "role": "user",
        "content": [
            {"type": "text", "text": "What's in this image?"},
            {
                "type": "image",
                "source": {
                    "type": "url",
                    "url": "https://example.com/image.jpg"
                }
            }
        ]
    }]
)

with open("image.png", "rb") as f:
    image_data = base64.b64encode(f.read()).decode()

message = client.messages.create(
    model="claude-sonnet-4-6",
    max_tokens=1024,
    messages=[{
        "role": "user",
        "content": [
            {"type": "text", "text": "Describe this image"},
            {
                "type": "image",
                "source": {
                    "type": "base64",
                    "media_type": "image/png",
                    "data": image_data
                }
            }
        ]
    }]
)

Tool Kullanımı

message = client.messages.create(
    model="claude-sonnet-4-6",
    max_tokens=1024,
    tools=[{
        "name": "get_weather",
        "description": "Get the weather for a location",
        "input_schema": {
            "type": "object",
            "properties": {
                "location": {"type": "string"}
            },
            "required": ["location"]
        }
    }],
    messages=[{"role": "user", "content": "What's the weather in Tokyo?"}]
)

for block in message.content:
    if block.type == "tool_use":
        print(block.name)
        print(block.input)

Genişletilmiş Düşünme

message = client.messages.create(
    model="claude-opus-4-6",
    max_tokens=16000,
    thinking={
        "type": "enabled",
        "budget_tokens": 10000
    },
    messages=[{"role": "user", "content": "Solve this complex problem step by step."}]
)

for block in message.content:
    if block.type == "thinking":
        print(block.thinking)
    elif block.type == "text":
        print(block.text)

Önerilen Claude Modelleri

ModelEn Uygun Olduğu Alan
claude-opus-4-6Derin muhakeme, uzun biçimli analiz
claude-sonnet-4-6Kodlama, genel asistan görevleri
claude-haiku-4-5Hızlı, hafif yanıtlar

Sorun Giderme

  • https://api.lemondata.cc kullanın
  • Anthropic SDK’yı yapılandırırken /v1 ekini manuel olarak eklemeyin
  • LemonData API anahtarınızın sk- ile başladığını kontrol edin
  • Anahtarın LemonData dashboard içinde aktif olduğunu doğrulayın
  • Özel header’ları manuel olarak eklemek yerine auth header’ını Anthropic SDK’nın yönetmesine izin verin
  • Claude model adını tam olarak doğrulayın
  • LemonData model kataloğundaki güncel kullanılabilirliği kontrol edin