from noxus_sdk.client import Client# Initialize with your API keyclient = Client(api_key="your_api_key_here")# Or use environment variableimport osclient = Client(api_key=os.getenv("NOXUS_API_KEY"))# For custom backend URL (if needed)client = Client( api_key="your_api_key_here", base_url="https://your-custom-backend.com")
You can also set the NOXUS_BACKEND_URL environment variable instead of
passing base_url directly.
from noxus_sdk.client import Clientfrom noxus_sdk.resources.conversations import ConversationSettings, MessageRequest# Initialize the clientclient = Client(api_key="your_api_key_here")# Configure conversation settingssettings = ConversationSettings( model=["gpt-4o-mini"], temperature=0.7, max_tokens=150, tools=[], extra_instructions="Be helpful and concise.")# Create a new conversationconversation = client.conversations.create( name="My First Conversation", settings=settings)print(f"Created conversation: {conversation.id}")# Send a messagemessage = MessageRequest(content="Hello! What can you help me with?")response = conversation.add_message(message)print(f"AI Response: {response.message_parts}")
from noxus_sdk.workflows import WorkflowDefinition# Create a workflow definitionworkflow_def = WorkflowDefinition(name="Hello World Workflow")# Add nodesinput_node = workflow_def.node("InputNode").config( label="User Input", fixed_value=True, value="Tell me a fun fact about space", type="str")ai_node = workflow_def.node("TextGenerationNode").config( template="Answer this question: ((Input 1))", model=["gpt-4o-mini"])output_node = workflow_def.node("OutputNode")# Connect the nodesworkflow_def.link(input_node.output(), ai_node.input("variables", "Input 1"))workflow_def.link(ai_node.output(), output_node.input())# Save the workflowworkflow = client.workflows.save(workflow_def)print(f"Created workflow: {workflow.id}")# Run the workflowrun = workflow.run(body={})result = run.wait(interval=2)print(f"Workflow result: {result.output}")
# List available AI modelsmodels = client.get_models()print("Available models:")for model in models[:3]: # Show first 3 print(f"- {model['name']}")# List available workflow nodesnodes = client.get_nodes()print(f"\nAvailable node types: {len(nodes)}")for node in nodes[:5]: # Show first 5 print(f"- {node['type']}")# Get chat presetspresets = client.get_chat_presets()print(f"\nAvailable chat presets: {len(presets)}")
# Create a support bot with knowledge base integrationfrom noxus_sdk.resources.conversations import ( ConversationSettings, KnowledgeBaseQaTool)kb_tool = KnowledgeBaseQaTool( enabled=True, kb_id="your_kb_id", extra_instructions="Provide helpful support answers")settings = ConversationSettings( model=["gpt-4o-mini"], tools=[kb_tool], extra_instructions="You are a helpful customer support agent.")support_bot = client.conversations.create( name="Support Bot", settings=settings)
Document Processing Workflow
# Create a workflow that processes and summarizes documents
Copy
Ask AI
workflow_def = WorkflowDefinition(name="Document Processor") input_node =workflow_def.node("InputNode").config( label="Document Input" ) summarizer =workflow_def.node("SummaryNode").config( summary_format="Bullet Points",summary_topic="Key insights and action items" ) output_node =workflow_def.node("OutputNode") workflow_def.link(input_node.output(),summarizer.input()) workflow_def.link(summarizer.output(),output_node.input()) processor = client.workflows.save(workflow_def) ```</Accordion><Accordion title="Research Assistant Agent" icon="search"> ```python # Create an agent that can research topics using web search from noxus_sdk.resources.conversations import WebResearchTool web_tool = WebResearchTool( enabled=True, extra_instructions="Focus on recent and reliable sources" ) agent_settings = ConversationSettings( model=["gpt-4o-mini"], tools=[web_tool], extra_instructions="You are a research assistant. Provide well-sourced information." ) research_agent = client.agents.create( name="Research Assistant", settings=agent_settings )