Skip to main content
Archived

This project has been archived by its maintainers, and is no longer receiving any updates.

langchain-predictionguard

Migrating

The Prediction Guard API is compatible with both OpenAI-style and Anthropic-style clients, so the standard LangChain integrations work with it directly. Use whichever matches the functionality you need, pointed at the Prediction Guard API with your existing API key.

This package Replacement
ChatPredictionGuard langchain_openai.ChatOpenAI or langchain_anthropic.ChatAnthropic
PredictionGuard (completions) langchain_openai.OpenAI
PredictionGuardEmbeddings langchain_openai.OpenAIEmbeddings
PredictionGuardRerank No drop-in replacement; call the Prediction Guard /rerank endpoint directly

Chat (OpenAI-compatible)

pip install langchain-openai
import os

from langchain_openai import ChatOpenAI

chat = ChatOpenAI(
    model="<model-name>",
    api_key=os.environ["PREDICTIONGUARD_API_KEY"],
    base_url="https://api.predictionguard.com",
)

chat.invoke("Tell me a joke")

Chat (Anthropic-compatible)

pip install langchain-anthropic
import os

from langchain_anthropic import ChatAnthropic

chat = ChatAnthropic(
    model="<model-name>",
    api_key=os.environ["PREDICTIONGUARD_API_KEY"],
    base_url="https://api.predictionguard.com",
)

chat.invoke("Tell me a joke")

Completions

import os

from langchain_openai import OpenAI

llm = OpenAI(
    model="<model-name>",
    api_key=os.environ["PREDICTIONGUARD_API_KEY"],
    base_url="https://api.predictionguard.com",
)

llm.invoke("Tell me a joke about bears")

Embeddings

import os

from langchain_openai import OpenAIEmbeddings

embeddings = OpenAIEmbeddings(
    model="<model-name>",
    api_key=os.environ["PREDICTIONGUARD_API_KEY"],
    base_url="https://api.predictionguard.com",
    # Send raw text rather than OpenAI tiktoken token IDs.
    check_embedding_ctx_length=False,
)

embeddings.embed_query("This is an embedding example.")

For the full list of endpoints and models, see the Prediction Guard documentation.

Metadata

Release files for langchain-predictionguard 0.4.0

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for langchain-predictionguard 0.4.0
File Size Uploaded Provenance
langchain_predictionguard-0.4.0.tar.gz 101.3 kB Without provenance Details

Built distribution (wheel)

Table of built distributions (wheels) for langchain-predictionguard 0.4.0
File Interpreter ABI Platform
langchain_predictionguard-0.4.0-py3-none-any.whl Python 3 none any Details

Total release size: 115.5 kB

Release files / langchain_predictionguard-0.4.0.tar.gz

Download URL langchain_predictionguard-0.4.0.tar.gz
Size 101.3 kB
Tags Source
SHA-256 checksum
How to use checksums
510fd315f650b12a2493f70ce9fd1d9a136d4e79a03f3046e41c6cf73a7578db
BLAKE2b-256 checksum
How to use checksums
24c573007c2fb9fc965392241cd01e0b401252ad70b8dfc2d081875e1edd2a9e
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via uv/0.12.19 {"installer":{"name":"uv","version":"0.12.19","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"24.04","id":"noble","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}

Release files / langchain_predictionguard-0.4.0-py3-none-any.whl

Download URL langchain_predictionguard-0.4.0-py3-none-any.whl
Size 14.2 kB
Tags Python 3
SHA-256 checksum
How to use checksums
c1e022e106c4b46929b0249f49f55fb353d30198d541dcffb40a0d23e12c32eb
BLAKE2b-256 checksum
How to use checksums
c2c207e209465dede7c58d04c6dc95b44716792bf2e9a24ebefa000c942e7dc1
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via uv/0.12.19 {"installer":{"name":"uv","version":"0.12.19","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"24.04","id":"noble","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}

Security for langchain-predictionguard 0.4.0

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

No provenance found

None of the files in this release were uploaded with provenance metadata.

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page