Skip to main content

PNS AI Hub SDK - AI 서비스를 쉽게 사용할 수 있는 Python SDK

Project description

PNS AI SDK for Python

PNS AI Hub 서비스를 쉽게 사용할 수 있는 Python SDK입니다.

설치

pip install pnslab-ai-sdk

빠른 시작

from pns_ai import AIClient

# 클라이언트 생성
client = AIClient(
    api_key="pns_sk_live_xxx",      # API 키
    encryption_key="your_64_hex"     # 암호화 키
)

# AI와 대화
response = client.chat("안녕하세요!")
print(response.text)

스트리밍

# 실시간 스트리밍 응답
for chunk in client.chat_stream("긴 이야기를 해줘"):
    print(chunk, end="", flush=True)

모델 선택

# Claude Sonnet 4.5 (기본값, 가장 추천)
response = client.chat("질문", model="claude-sonnet-4.5")

# Nova Lite (빠른 응답)
response = client.chat("질문", model="nova-lite")

옵션 설정

response = client.chat(
    message="창의적인 이야기를 해줘",
    model="claude-sonnet-4.5",
    max_tokens=2000,        # 최대 응답 길이
    temperature=0.9,        # 창의성 (0.0~1.0)
    system="당신은 창의적인 작가입니다"  # 시스템 프롬프트
)

사용량 확인

usage = client.get_usage()
print(f"이번 달 사용: {usage['currentMonthTokens']:,} 토큰")
print(f"남은 토큰: {usage['remainingTokens']:,}")

에러 처리

from pns_ai import AIClient, AuthenticationError, TokenLimitError

try:
    response = client.chat("안녕")
except AuthenticationError:
    print("API 키가 올바르지 않습니다")
except TokenLimitError:
    print("이번 달 토큰 한도를 초과했습니다")

API 키 발급

API 키는 PNS Portal에서 발급받을 수 있습니다.

라이선스

MIT License

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

pnslab_ai_sdk-1.0.0.tar.gz (6.8 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

pnslab_ai_sdk-1.0.0-py3-none-any.whl (7.3 kB view details)

Uploaded Python 3

File details

Details for the file pnslab_ai_sdk-1.0.0.tar.gz.

File metadata

  • Download URL: pnslab_ai_sdk-1.0.0.tar.gz
  • Upload date:
  • Size: 6.8 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.9.24

File hashes

Hashes for pnslab_ai_sdk-1.0.0.tar.gz
Algorithm Hash digest
SHA256 af3879ce3b2302e7aa93454fa0ac045a01f1c5d44136822ed9d8339022c2b8a5
MD5 c01098ee6b845cba4e6a23060c9136a3
BLAKE2b-256 81056fd4a06bb3d35c7852f07bff9f4330b3f92d65741bed8c4b0d66ab192538

See more details on using hashes here.

File details

Details for the file pnslab_ai_sdk-1.0.0-py3-none-any.whl.

File metadata

  • Download URL: pnslab_ai_sdk-1.0.0-py3-none-any.whl
  • Upload date:
  • Size: 7.3 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.9.24

File hashes

Hashes for pnslab_ai_sdk-1.0.0-py3-none-any.whl
Algorithm Hash digest
SHA256 10a0c3bc0a56e25121f6128078de7b1e1ad40e5c2ad414ee356488fcdd7f7352
MD5 e5ee5aae992525a864a3efa3ff1bd2df
BLAKE2b-256 899411c8ead7ecdae1e0b41347eea15f44403068998bf973f1e39df47e7a6547

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page