Official Python SDK for the CodeVF API
Project description
CodeVF Python SDK
The official Python client for the CodeVF API. This SDK provides a synchronous, typed wrapper around CodeVF's engineering automation platform to help you manage projects, submit human-review prompts, monitor credits, and choose engineer expertise levels.
Features
- Project Management – Create and organize reusable projects that group related tasks.
- Task Submission – Submit prompts, attachments, metadata, and SLA mode preferences for human engineer review.
- Credit System – Monitor available, on-hold, and total credits so you can budget work before submission.
- Engineer Expertise – Fetch tag metadata and choose expertise levels with documented cost multipliers.
- File Attachments – Attach code files, logs, screenshots, and other assets with helper validation to stay within size limits.
- Comprehensive Error Handling – Typed exceptions for each HTTP failure mode, plus helpers for retries and validation.
Quick Start
Installation
pip install codevf-sdk
Basic Usage
from decimal import Decimal
from codevf import (
CodeVFClient,
ServiceMode,
calculate_final_credit_cost,
validate_metadata,
)
client = CodeVFClient(api_key="cvf_live_...")
project = client.projects.create(
name="API Automation",
description="Unify reliability checks for the new integration",
)
metadata = validate_metadata({"environment": "production"})
estimate = calculate_final_credit_cost(50, ServiceMode.FAST, Decimal("1.6"))
task = client.tasks.create(
prompt="Review and document this authentication flow.",
max_credits=50,
project_id=project.id,
mode=ServiceMode.FAST,
metadata=metadata,
attachments=[
{"fileName": "auth.md", "mimeType": "text/markdown", "content": "# audit notes"},
],
)
status = client.tasks.retrieve(task.id)
balance = client.credits.get_balance()
tags = client.tags.list()
Initialize the client with CodeVFClient, create a project, submit a task with metadata and attachments, then poll its status and check your credit balance. Use tags.list() to discover engineer expertise levels and associated cost multipliers before choosing a tag_id.
Architecture
The SDK mirrors the API surface with a clear separation of concerns:
- Core —
CodeVFClient(src/codevf/client.py) handles authentication, retries, base URL configuration, and request plumbing. - Resources —
Projects,Tasks,Credits, andTagsinsrc/codevf/resourceswrap each API domain and normalize payloads into typed models. - Models —
src/codevf/modelsdefinesProject,TaskResponse,CreditBalance,Tag,TaskDeliverable, and helpers such ascalculate_final_credit_costandnormalize_attachments. - Utilities — helpers such as
validate_metadataenforce metadata rules and attachment limits before requests go out.
API Reference
Projects
client.projects.create(name, description=None)— create or reuse a named project and receive aProjectmodel.
Tasks
client.tasks.create(...)— submit prompts, attachments, metadata, tag IDs, SLA modes, and optional idempotency keys; the helper enforces prompt length, credit bounds, and attachment limits before making the request.client.tasks.retrieve(task_id)— poll task status, deliverables, and credit usage.client.tasks.cancel(task_id)— cancel pending or processing tasks.
Credits
client.credits.get_balance()— retrieve aCreditBalanceobject withavailable,on_hold, andtotalcredits.
Tags
client.tags.list()— list engineer expertise tags withcost_multiplier,is_active, and metadata to help you pick the right expertise level.
Error Handling
Typed exceptions in codevf.exceptions map raw API responses to actionable error classes so you can respond precisely to each failure mode. Common exceptions include AuthenticationError (401/403), RateLimitError (429), MaxCreditsExceededError, InvalidModeError, InvalidTagError, InvalidMetadataError, InsufficientCreditsError, AttachmentLimitExceededError, AttachmentTooLargeError, PayloadTooLargeError, ServerError (5xx), and APIConnectionError.
from codevf.exceptions import AuthenticationError, RateLimitError
try:
client.credits.get_balance()
except AuthenticationError:
# refresh the API key or rotate your environment secret
...
except RateLimitError:
# honor Retry-After before retrying
...
Running Tests
pytest
Tests live under /tests and mirror the package structure to keep fixtures aligned with production resources.
Smoke Script
The scripts/integration_smoke.py script walks through the core endpoints (project creation/reuse, tag listing, task submission/cancellation, and balance checks). Export your API key before running:
export CODEVF_API_KEY="cvf_live_..." # use `setx` or PowerShell's `Set-Item` on Windows
python scripts/integration_smoke.py
Development
git clone https://github.com/codevf/codevf-sdk-python.git
pip install -e .[dev]
pytest
ruff check src tests
mypy
Install dev dependencies with pip install -e .[dev], then run pytest, ruff check, and mypy for linting and type coverage.
Requirements
- Python 3.9 or newer
requests>=2.25.0- Optional dev dependencies:
pytest,ruff,mypy,types-requests
License
MIT — see the LICENSE file for details.
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file codevf_sdk-0.1.0.tar.gz.
File metadata
- Download URL: codevf_sdk-0.1.0.tar.gz
- Upload date:
- Size: 17.0 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.9.13
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
5e6b18b1c74d6a9e7e69da0f4fa7b708b4e27b86b21049a7c1e6039c31aa5bae
|
|
| MD5 |
58d0eb1548246d8ba91a9a0bcb25f3db
|
|
| BLAKE2b-256 |
c29c05fe534c921132e22af27d1c49b34887e5ea350117a50d750f39b71f4806
|
File details
Details for the file codevf_sdk-0.1.0-py3-none-any.whl.
File metadata
- Download URL: codevf_sdk-0.1.0-py3-none-any.whl
- Upload date:
- Size: 18.2 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.9.13
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
738a090415848b60d54be68ad367dd2abff43885f54d5d037ada67b9d5b2b69e
|
|
| MD5 |
5b93c51f451acd402c71fd9d47e2c079
|
|
| BLAKE2b-256 |
26266c88b4d02595697df027214746588705ada626e03c918d25cd35170d8305
|