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.6.tar.gz (11.2 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.6-py3-none-any.whl (15.1 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: specific_ai-0.1.6.tar.gz
  • Upload date:
  • Size: 11.2 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.6.tar.gz
Algorithm Hash digest
SHA256 2c5f2908914227e652b7f51d126adee53da959272116671e39fc115e4b374c48
MD5 da962909605c4467a165e2b605cb178a
BLAKE2b-256 0197ef662180c8d3365d70dade77d644d78b3086705a15d0b7058e54dc700fd0

See more details on using hashes here.

File details

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

File metadata

  • Download URL: specific_ai-0.1.6-py3-none-any.whl
  • Upload date:
  • Size: 15.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.6-py3-none-any.whl
Algorithm Hash digest
SHA256 fc81d7bc4a1b0e0ab18611b4b55b4839bbe4d6383922c8ec36a6f35c961875ef
MD5 3efaebf88e8fed7dac32b27ef9ce01c1
BLAKE2b-256 0e016f1c7b95dd74ab7c79969a779337139c546563c7362bb212a4963d723dcc

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