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.5.tar.gz (11.0 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.5-py3-none-any.whl (14.9 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: specific_ai-0.1.5.tar.gz
  • Upload date:
  • Size: 11.0 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.5.tar.gz
Algorithm Hash digest
SHA256 73bf6022303446f417699812c7eed601c2d3a839bce9fa8fe63cbe0a8fa4d7d0
MD5 5595119567e3add424cd447023872166
BLAKE2b-256 a2434de88fdcbb521650c4efb832d01f4adf687bfeb00f4fdcec97e357d064da

See more details on using hashes here.

File details

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

File metadata

  • Download URL: specific_ai-0.1.5-py3-none-any.whl
  • Upload date:
  • Size: 14.9 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.5-py3-none-any.whl
Algorithm Hash digest
SHA256 530e39183d262b5a430ca9579ca97e426a1b701ce43b74bba2fea371eecc48e6
MD5 e9b601f53f042832567be2898945dfd7
BLAKE2b-256 3f244c928ee4b3af95ab94a43893bb824e05507669f32ce85a53ef5198974700

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