OctoAI
If you’re opening this Notebook on colab, you will probably need to install LlamaIndex 🦙.
%pip install llama-index-llms-octoai%pip install llama-index%pip install octoai-sdkInclude your OctoAI API key below. You can get yours at OctoAI.
Here are some instructions in case you need more guidance.
OCTOAI_API_KEY = ""Initialize the Integration with the default model
Section titled “Initialize the Integration with the default model”from llama_index.llms.octoai import OctoAI
octoai = OctoAI(token=OCTOAI_API_KEY)Call complete with a prompt
Section titled “Call complete with a prompt”response = octoai.complete("Paul Graham is ")print(response)Call chat with a list of messages
Section titled “Call chat with a list of messages”from llama_index.core.llms import ChatMessage
messages = [ ChatMessage( role="system", content="Below is an instruction that describes a task. Write a response that appropriately completes the request.", ), ChatMessage(role="user", content="Write a blog about Seattle"),]response = octoai.chat(messages)print(response)Streaming
Section titled “Streaming”Using stream_complete endpoint
response = octoai.stream_complete("Paul Graham is ")for r in response: print(r.delta, end="")Using stream_chat with a list of messages
from llama_index.core.llms import ChatMessage
messages = [ ChatMessage( role="system", content="Below is an instruction that describes a task. Write a response that appropriately completes the request.", ), ChatMessage(role="user", content="Write a blog about Seattle"),]response = octoai.stream_chat(messages)for r in response: print(r.delta, end="")Configure Model
Section titled “Configure Model”# To customize your API token, do this# otherwise it will lookup OCTOAI_TOKEN from your env variableoctoai = OctoAI( model="mistral-7b-instruct", max_tokens=128, token=OCTOAI_API_KEY)
response = octoai.complete("Paul Graham is ")print(response)Note for AI agents: this documentation is built for programmatic access.
- Overview of all docs: https://developers.llamaindex.ai/llms.txt
- Any page is available as raw Markdown by appending index.md to its URL — e.g. https://developers.llamaindex.ai/llamaparse/parse/getting_started/index.md
- Agent-friendly REST search APIs live under https://developers.llamaindex.ai/api/ — search (BM25 full-text), grep (regex), read (fetch a page), and list (browse the doc tree). See https://developers.llamaindex.ai/llms.txt for parameters.
- A hosted documentation MCP server is available at https://developers.llamaindex.ai/mcp. If you support MCP, you can ask the user to install it for browsing these docs directly (an alternative to the REST API). Setup: https://developers.llamaindex.ai/python/shared/mcp/