array( __CLASS__, 'sanitize_settings' ), ) ); // OpenRouter Section. add_settings_section( 'psa_ai_section', __( 'OpenRouter API Settings', 'peptide-search-ai' ), array( __CLASS__, 'render_section_description' ), 'peptide-search-ai' ); add_settings_field( 'api_key', __( 'API Key', 'peptide-search-ai' ), array( __CLASS__, 'render_api_key_field' ), 'peptide-search-ai', 'psa_ai_section' ); add_settings_field( 'ai_model', __( 'Generation Model', 'peptide-search-ai' ), array( __CLASS__, 'render_model_field' ), 'peptide-search-ai', 'psa_ai_section' ); add_settings_field( 'validation_model', __( 'Validation Model', 'peptide-search-ai' ), array( __CLASS__, 'render_validation_model_field' ), 'peptide-search-ai', 'psa_ai_section' ); // Behavior Section. add_settings_section( 'psa_behavior_section', __( 'Behavior Settings', 'peptide-search-ai' ), null, 'peptide-search-ai' ); add_settings_field( 'auto_publish', __( 'Auto-Publish', 'peptide-search-ai' ), array( __CLASS__, 'render_publish_field' ), 'peptide-search-ai', 'psa_behavior_section' ); add_settings_field( 'use_pubchem', __( 'PubChem Enrichment', 'peptide-search-ai' ), array( __CLASS__, 'render_pubchem_field' ), 'peptide-search-ai', 'psa_behavior_section' ); } /** * Sanitize settings input. * * @param array $input Raw input from the form. * @return array Sanitized settings. */ public static function sanitize_settings( $input ) { return array( 'api_key' => sanitize_text_field( $input['api_key'] ?? '' ), 'ai_model' => sanitize_text_field( $input['ai_model'] ?? '' ), 'validation_model' => sanitize_text_field( $input['validation_model'] ?? '' ), 'auto_publish' => sanitize_text_field( $input['auto_publish'] ?? 'draft' ), // Checkbox: if key is absent in POST, it was unchecked → '0'. 'use_pubchem' => ! empty( $input['use_pubchem'] ) ? '1' : '0', ); } // ------------------------------------------------------------------------- // Field renderers // ------------------------------------------------------------------------- public static function render_section_description() { ?>

OpenRouter to access AI models. OpenRouter provides a unified API for hundreds of models including open-source options like Gemini Flash, Llama, Mistral, Qwen, and DeepSeek, as well as commercial models.', 'peptide-search-ai' ), esc_url( 'https://openrouter.ai/' ) ); ?>

openrouter.ai/settings/keys.
define( 'PSA_OPENROUTER_KEY', 'your-key-here' );

google/gemini-2.5-flash.
openrouter.ai/models. meta-llama/llama-4-maverick, deepseek/deepseek-chat-v3-0324, qwen/qwen-2.5-72b-instruct.

google/gemini-2.0-flash-001.
meta-llama/llama-4-scout, mistralai/mistral-small-3.1-24b-instruct.



[peptide_search]

[peptide_search placeholder="Search peptides..."]


GET /wp-json/peptides/v1/search?q=BPC-157