Skip to main content

Plugin for LLM adding fast Cerebras inference API support

Project description

llm-cerebras

This is a plugin for LLM that adds support for the Cerebras inference API.

Installation

Install this plugin in the same environment as LLM.

pip install llm-cerebras

Configuration

You'll need to provide an API key for Cerebras.

llm keys set cerebras

Listing available models

llm models list | grep cerebras
# cerebras-llama3.1-8b - Cerebras
# cerebras-llama3.3-70b - Cerebras
# cerebras-deepseek-r1-distill-llama-70b - Cerebras

Schema Support

The llm-cerebras plugin supports schemas for structured output. You can use either compact schema syntax or full JSON Schema:

# Using compact schema syntax
llm -m cerebras-llama3.3-70b 'invent a dog' --schema 'name, age int, breed'

# Using multi-item schema for lists
llm -m cerebras-llama3.3-70b 'invent three dogs' --schema-multi 'name, age int, breed'

# Using full JSON Schema 
llm -m cerebras-llama3.3-70b 'invent a dog' --schema '{
  "type": "object",
  "properties": {
    "name": {"type": "string"},
    "age": {"type": "integer"},
    "breed": {"type": "string"}
  },
  "required": ["name", "age", "breed"]
}'

Schema with Descriptions

You can add descriptions to your schema fields to guide the model:

llm -m cerebras-llama3.3-70b 'invent a famous scientist' --schema '
name: the full name including any titles
field: their primary field of study
year_born int: year of birth
year_died int: year of death, can be null if still alive
achievements: a list of their major achievements
'

Creating Schema Templates

You can save schemas as templates for reuse:

# Create a template
llm -m cerebras-llama3.3-70b --schema 'title, director, year int, genre' --save movie_template

# Use the template
llm -t movie_template 'suggest a sci-fi movie from the 1980s'

Development

To set up this plugin locally, first checkout the code. Then create a new virtual environment:

cd llm-cerebras
python -m venv venv
source venv/bin/activate

Now install the dependencies and test dependencies:

pip install -e '.[test]'

Running Tests

To run the unit tests:

pytest tests/test_cerebras.py tests/test_schema_support.py

To run integration tests (requires a valid API key):

pytest tests/test_integration.py

To run automated user workflow tests:

pytest tests/test_automated_user.py

You can run specific test types using markers:

pytest -m "integration"  # Run only integration tests
pytest -m "user"         # Run only user workflow tests

License

Apache 2.0

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

llm_cerebras-0.1.7.tar.gz (11.0 kB view details)

Uploaded Source

Built Distribution

llm_cerebras-0.1.7-py3-none-any.whl (6.7 kB view details)

Uploaded Python 3

File details

Details for the file llm_cerebras-0.1.7.tar.gz.

File metadata

  • Download URL: llm_cerebras-0.1.7.tar.gz
  • Upload date:
  • Size: 11.0 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.13.2

File hashes

Hashes for llm_cerebras-0.1.7.tar.gz
Algorithm Hash digest
SHA256 92dc99be5c02b96f058f8e1eefd234d6d4dedf41311236f5edeb6c0c10295d8d
MD5 a27af656d5c0a920ba35daa2cecb953f
BLAKE2b-256 f555f76197e7b1c617135e1f36fc2d21d29b4ef82cbfa5430dc009e5fdd97e8d

See more details on using hashes here.

File details

Details for the file llm_cerebras-0.1.7-py3-none-any.whl.

File metadata

  • Download URL: llm_cerebras-0.1.7-py3-none-any.whl
  • Upload date:
  • Size: 6.7 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.13.2

File hashes

Hashes for llm_cerebras-0.1.7-py3-none-any.whl
Algorithm Hash digest
SHA256 936551e22248e23531f4e42d28cd4ac8d2c526efbcbdc9512691278e808eeabf
MD5 b9fcc9a40724a92cf120aaab178338f1
BLAKE2b-256 638844199b92e0d2d46782eb089f950353dc612fd1731206c2d7e480083ae5be

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page