Implementing Retrieval-Augmented Generation (RAG) with ZC Technologies can be straightforward and cost-effective. This post outlines three minimal recipes for developers building RAG applications, using the OpenAI-compatible API of ZC Inference Exchange. ZC Inference Exchange serves Qwen 2.5 models on dedicated NVIDIA GB10 silicon, offering a cost advantage over Anthropic and OpenAI. We'll cover setting up a RAG pipeline, integrating with LangChain, and leveraging LlamaIndex for document retrieval. Each example is designed to be minimal and efficient, with pricing details provided for the ZC subscription plans.
To begin, let's set up a basic RAG pipeline using the ZC Inference Exchange API. This example will use the Qwen 2.5:32b model, which is available on the Starter plan for $99/mo, offering 1.5M tokens at $66/1M.
import requests
# Replace 'your_bearer_token' with your actual Bearer token
headers = {
'Authorization': 'Bearer your_bearer_token',
'Content-Type': 'application/json'
}
# Define the API endpoint
url = 'https://zcx.zctechnologies.org/v1/chat'
# Example request payload
payload = {
'model': 'qwen2.5:32b',
'messages': [{'role': 'system', 'content': 'You are a helpful assistant.'},
{'role': 'user', 'content': 'What is the capital of France?'}]
}
# Send the request
response = requests.post(url, headers=headers, json=payload)
# Print the response
print(response.json())
LangChain is a framework for building scalable applications with LLMs. To integrate LangChain with ZC Inference Exchange, you can follow the steps below. This example uses the Pro plan, which includes the Qwen 2.5:72b model for $499/mo, offering 12.0M tokens at $42/1M.
from langchain import LLMChain, PromptTemplate
from langchain.llms import ZC
zc_llm = ZC(model_name='qwen2.5:72b', bearer_token='your_bearer_token')
prompt = PromptTemplate(
input_variables=['query'],
template='Answer the following question: {query}'
)
chain = LLMChain(llm=zc_llm, prompt=prompt)
response = chain.run('What is the capital of France?')
print(response)
LlamaIndex is a library for building document retrieval systems. By integrating LlamaIndex with ZC Inference Exchange, you can create a powerful RAG system. This example uses the Business plan, which includes both Qwen 2.5 models for $1999/mo, offering 60.0M tokens at $33/1M.
from llama_index import GPTVectorStoreIndex, SimpleDirectoryReader
from llama_index.llms import ZC
# Initialize LlamaIndex with ZC Inference Exchange
zc_llm = ZC(model_name='qwen2.5:72b', bearer_token='your_bearer_token')
# Load documents from a directory
documents = SimpleDirectoryReader('path/to/documents').load_data()
# Build the index
index = GPTVectorStoreIndex.from_documents(documents, llm=zc_llm)
# Query the index
query_engine = index.as_query_engine()
response = query_engine.query('What is the capital of France?')
print(response)
To learn more about ZC Inference Exchange and the pricing plans, visit our website.