Skip to content

Conversation

@willchrisjr
Copy link

  • Environment Variables

    • Add OPENROUTER_TOKEN to .env file
  • Module Imports and Exports

    • Import openrouter module in index.js
    • Add openrouter to exported modules in index.js
  • Anthropic Inference Function

    • Import openrouter module in anthropic.js
    • Add condition to check for OPENROUTER_TOKEN and use it if available in anthropic.js

* **Environment Variables**
  - Add `OPENROUTER_TOKEN` to `.env` file

* **Module Imports and Exports**
  - Import `openrouter` module in `index.js`
  - Add `openrouter` to exported modules in `index.js`

* **Anthropic Inference Function**
  - Import `openrouter` module in `anthropic.js`
  - Add condition to check for `OPENROUTER_TOKEN` and use it if available in `anthropic.js`
@willchrisjr willchrisjr closed this Nov 1, 2024
@willchrisjr willchrisjr reopened this Nov 1, 2024
import fetch from "node-fetch";

async function inference({ model, messages, stream = process.stdout }) {
const response = await fetch("https://api.openrouter.ai/v1/chat/completions", {
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

URL should be just https://openrouter.ai/v1/chat/completions

https://openrouter.ai/docs/quick-start

@codybmenefee
Copy link

codybmenefee commented Nov 3, 2024

keep running into a API Payload Too Large issue with the OpenRouter API. Anyone else?

{ asyncretry_error: { id: 'op:LLM::GEN', error: Error: OpenRouter API request failed: Payload Too Large at Object.inference (file:///Users/codymenefee/Documents/DevProjects/cofounder/api/utils/openrouter.js:20:9) at process.processTicksAndRejections (node:internal/process/task_queues:95:5) at async Object.opLlmGen [as op:LLM::GEN] (file:///Users/codymenefee/Documents/DevProjects/cofounder/api/system/functions/op/llm.js:66:26) at async file:///Users/codymenefee/Documents/DevProjects/cofounder/api/build.js:87:30 at async file:///Users/codymenefee/Documents/DevProjects/cofounder/api/build.js:84:25 at async file:///Users/codymenefee/Documents/DevProjects/cofounder/api/node_modules/p-queue/dist/index.js:187:36 } }

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants