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.4.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.4-py3-none-any.whl (14.1 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: specific_ai-0.1.4.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.4.tar.gz
Algorithm Hash digest
SHA256 8ab9d6d4abeb7c4a73d277b5415db24c4f2404da3464b5c856dc417bd3420fa7
MD5 cd123c28f68b750ea38e50f6ddb9b261
BLAKE2b-256 eef1faf34360f5e6cbca36bb1988b043fea60858c92bce661382580ec162e51c

See more details on using hashes here.

File details

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

File metadata

  • Download URL: specific_ai-0.1.4-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.4-py3-none-any.whl
Algorithm Hash digest
SHA256 0da23c5ae6a9cddbcf4f15d7680be2f5b3595cfcb5e7c2dca5f59cebc0d72886
MD5 25f4b1048bfcd939c47ca1220ba60a79
BLAKE2b-256 53e5f51acab3e4841d759a753e922ced04cf79c889a49fa72e8b4d6281667f3e

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