Skip to main content

specific.ai python sdk

Project description

Specific.ai SDK

Installation

pip install specific-ai

Quick Start

OpenAI

from specific_ai import OpenAI

# Initialize the client
client = OpenAI(
    specific_ai_url="<your-specific-ai-service-URL>",
    api_key="<your-openai-api-key>",
    use_specific_ai_inference=False,
)

# Use like regular OpenAI client with the SpecificAI additional field
response = client.chat.completions.create(
    model="gpt-3.5-turbo",
    messages=[
        {"role": "user", "content": "Hello!"}
    ],
    specific_ai={
        "task_name": "greeting",
    }
)

print(response.choices[0].message.content)

Anthropic

from specific_ai import Anthropic

# Initialize the client
client = Anthropic(
    specific_ai_url="<your-specific-ai-service-URL>",
    api_key="<your-anthropic-api-key>",
    use_specific_ai_inference=False,
)

# Use like regular Anthropic client with the SpecificAI additional field
response = client.messages.create(
    model="claude-sonnet-4-20250514",
    messages=[
        {"role": "user", "content": "Hello!"}
    ],
    max_tokens=1000,
    specific_ai={
        "task_name": "greeting",
    }
)

print(response.content[0].text)

Features

  • 🎯 Custom-tailored models optimized for your specific use cases
  • 🚀 Works with OpenAI and Anthropic APIs
  • 📊 Automatic request and response logging
  • 🎯 Response optimization capabilities
  • 📈 Advanced analytics integration

Core Features Explained

Model Inference Options

The SDK offers two approaches to model inference, controlled by use_specific_ai_inference:

client = OpenAI(
    api_key="your-key",
    use_specific_ai_inference=True  # Enable SpecificAI's optimized models
)
  • Standard Inference (use_specific_ai_inference=False):

    • Uses the provider's models directly (OpenAI/Anthropic)
    • Standard pricing and performance
    • Data is collected for future optimization
  • Specific.ai Inference (use_specific_ai_inference=True):

    • Uses task-specific models optimized for your use cases
    • Potential improvements in performance and cost
    • Automatic fallback to standard models if needed
    • Requires prior data collection for model training

Best Practices

  1. Start with Data Collection:

    • Keep use_specific_ai_inference=False initially
    • This builds up training data for your use cases
    • Use collected data to train a specific model with Specific.ai
  2. Transition to Optimized Models:

    • Deploy your model with Specific.ai
    • Enable use_specific_ai_inference=True
    • Monitor performance improvements
  3. Testing New Features:

    • Use A/B testing between standard and optimized models
    • Compare performance metrics
    • Gradually roll out optimization to production

Logging

This SDK uses Python's standard logging module. To capture logs from the SDK, configure logging in your application:

import logging

# Basic console logging
logging.basicConfig(level=logging.INFO)

# Or for more detailed logs
logging.basicConfig(
    level=logging.INFO,
    format='%(asctime)s - %(name)s - %(levelname)s - %(message)s'
)

Support

Need help? Contact our support team at support@specific.ai

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

specific_ai-0.1.3.tar.gz (10.6 kB view details)

Uploaded Source

Built Distribution

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

specific_ai-0.1.3-py3-none-any.whl (14.1 kB view details)

Uploaded Python 3

File details

Details for the file specific_ai-0.1.3.tar.gz.

File metadata

  • Download URL: specific_ai-0.1.3.tar.gz
  • Upload date:
  • Size: 10.6 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.12.3

File hashes

Hashes for specific_ai-0.1.3.tar.gz
Algorithm Hash digest
SHA256 3a8dd230df8914cb069516dd7f380df7b29b3ea56ecc7fe68f31dbaaa95169b3
MD5 8fae9b917948452b12bda41eaebee1d7
BLAKE2b-256 7efb277d7fc1faeb15ade569db8e7b1a49221254c0bc086f785a7581ecd64f24

See more details on using hashes here.

File details

Details for the file specific_ai-0.1.3-py3-none-any.whl.

File metadata

  • Download URL: specific_ai-0.1.3-py3-none-any.whl
  • Upload date:
  • Size: 14.1 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.12.3

File hashes

Hashes for specific_ai-0.1.3-py3-none-any.whl
Algorithm Hash digest
SHA256 0208de0716157cfd02169197afa6f0d62e935c251af840302fb85f3e058939eb
MD5 75ee0f62515c830e8b76522c6ee807a9
BLAKE2b-256 94efa5a7a7d2dae8434bcaadc2334fe324ec86af3fae52873bf2650149b25574

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